Hi,

I have two tables: Image and PersistentImage, where the latter
inherits the former. In addition, PersistentImage has a foreign key to
itself (ie, all PersistentImage objects form a hierarchy among
themselves). I haven't been able to get this to work - first it
complained about wanting a primaryjoin, then it seemed to get confused
between the parent/children relation among PersistentImage objects and
the inheritance between PersistentImage and Image. Here are my
mappers:

mapper(
        Image,
        imageTable,
        polymorphic_on=imageTable.c.type,
        polymorphic_identity='Image'
        )

mapper(
        PersistentImage,
        persistentImageTable,
        inherits=Image,
        polymorphic_identity='PersistentImage',
        properties={
        'children': relation(PersistentImage, backref='parent')
        })

And here are the actual table definitions:

imageTable = Table('Images', metadata,
        Column('id', Integer, primary_key=True),
        Column('name', String(256), nullable=False),
        Column('type', String(30), nullable=False)
        )

persistentImageTable = Table('PersistentImages', metadata,
        Column('id', Integer, ForeignKey('Images.id'), primary_key=True),
        Column('parentId', Integer, ForeignKey('PersistentImages.id')),
        Column('userId', Integer, ForeignKey('Users.id'), nullable=False)
        )

Thanks!

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to