Kent
unread,May 17, 2012, 5:00:20 PM5/17/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to sqlal...@googlegroups.com
Suppose I am using single table polymorphic inheritance like the docs Employee/Manager/Engineer example. I have a relationship that I want to have a different cascade or loading strategy for, depending on the mapper. Can I inherit from the base mapper and override the property, like this:
employee_mapper = mapper(Employee, employees_table, \
polymorphic_on=employees_table.c.type, polymorphic_identity='employee',
properties={'customer':relationship(Customer, lazy=False, cascade='save-update,refresh-expire,merge')})
manager_mapper = mapper(Manager, inherits=employee_mapper,
polymorphic_identity='manager',
properties={'customer':relationship(Customer, lazy=True, cascade='save-update,refresh-expire')})
engineer_mapper = mapper(Engineer, inherits=employee_mapper,
polymorphic_identity='engineer',
properties={'customer':relationship(Customer, lazy=True, cascade='save-update,refresh-expire')})
Here, the 'customer' relationship only joined loads and merges for Employee, not Engineer nor Manager. Is this supported?