On Apr 28, 2008, at 12:07 PM, Gaetan de Menten wrote:
> pjoin = polymorphic_union({ > 'manager':managers_table, > 'engineer':engineers_table, > 'hacker':hackers_table > }, 'type', 'pjoin') > > mapper(Company, companies, properties={ > 'engineers':relation(Engineer, lazy=False, > enable_typechecks=False) > }) > employee_mapper = mapper(Employee, pjoin, > polymorphic_on=pjoin.c.type) > manager_mapper = mapper(Manager, managers_table, > inherits=employee_mapper, concrete=True, > polymorphic_identity='manager') > engineer_mapper = mapper(Engineer, engineers_table, > inherits=employee_mapper, concrete=True, > polymorphic_identity='engineer', > properties={'company': relation(Company)}) > hacker_mapper = mapper(Hacker, hackers_table, > inherits=engineer_mapper, > concrete=True, > polymorphic_identity='hacker', > properties={'company': relation(Company)}) OK...mapping Employee to pjoin is fine since its a "virtual" mapper. For engineer_mapper, it needs a selectable from which it can also load Hacker objects...this is the "pjoin2" polymorphic_union you've created in a later test. *but*, the engineer_mapper doesn't get mapped to it, it should use it as its "with_polymorphic" argument (which used to be handled by "select_table"): pjoin = polymorphic_union(...) pjoin2 = polymorphic_union(...) employee_mapper = mapper(Employee, pjoin, polymorphic_on=pjoin.c.type) manager_mapper = mapper(Manager, managers_table, inherits=employee_mapper, concrete=True, polymorphic_identity='manager') engineer_mapper = mapper(Engineer, engineers_table, with_polymorphic=('*', pjoin2), polymorphic_on=pjoin2.c.type, inherits=employee_mapper, concrete=True, polymorphic_identity='engineer') hacker_mapper = mapper(Hacker, hackers_table, inherits=engineer_mapper, concrete=True, polymorphic_identity='hacker') this should in theory also fix the "engineers" relation on Company. But as I've said many times (to svil, at least) concrete inheritance is something i havent gotten into much as of yet, largely due to the many inherent issues with it as well as its being a generally unpopular pattern, so there may still be issues with this setup (but let me know, since thats how it "should" work). In any case the unit tests which you were working from (im guessing test/orm/inheritance/concrete.py) should be patched to include this test (i.e. including Hacker, the polymorphic load, as well as the relation). Assuming it works we should also make sure the 0.5 branch (which isnt called that yet) can handle it too. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---