I'm attempting to use joined table polymorphism for various types of
activities.  Activities all share a few common features, a location, a
reference number, time, etc.  but some have some further attributes.
When I set up my map like so:
mapper(Activity, activities, polymorphic_on=activities.c.type,
 
polymorphic_identity='activity',
 
properties={'location':relation(Location, backref='activities'),
 
'item':relation(Item, backref='activities')})
mapper(Manifest, manifests, polymorphic_on=activities.c.type,
polymorphic_identity='manifest')

with tables like so:
activities = Table('ws_activities', meta.metadata,
                   Column('id', Integer, primary_key=True),
                   Column('package_id', Integer,
ForeignKey('ws_packages.id'), nullable=False),
                   Column('type', String(50), nullable=False),
                   Column('location_id', Integer,
ForeignKey("ws_locations.id"), nullable=True),
                   Column('activity_timestamp', DateTime,
nullable=True)
                   )

manifests = Table('ws_manifests', meta.metadata,
                   Column('activity_id', Integer,
ForeignKey('ws_activities.id'), primary_key=True),
                   Column('service_description', String(35),
nullable=True)
                  )

When I try to add a Manifest (a subclass of Activity) to the session,
I get this error:
sqlalchemy.exc.InvalidRequestError: Mapper 'Mapper|Manifest|
ws_manifest' has no property 'item'

It would be much, much easier from my end to have the parent mapping
appropriately cascade to the child classes rather than trying to do
nearly the same mapping for each child class.

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

Reply via email to