> How many levels I can inherit classes/tables without get something > wrong?
my tests go to 4, all works. And as all corner cases are already there, i guess any level above will work too. mixed inheritance (joined+concrete) also can be made to work, as long as polymoprhic_union() is fixed slightly - AND no real polymoprhism over concrete tables, that does not work on SA level / conceptualy. may i suggest, that u get dbcook.sf.net, model your whole hierarchy there (it is SIMPLE), then run it in generator mode (see usage/example/*) and see what equivalent SA source/calls it generates. maybe you are missing something (some mapper/relation parameters are tricky to guess). be ware, only joined_inheritance is of real use (single_table is not implemented). > let me show a simplest sample hierarchy: > > resource > / \ > person material > / \ > employee customer > > > now, I am creating a type column on resource to map persons and > materials, them I am creating another type column on person, to get > mapped the various types of persons. no u dont do it this way. u musthave only one discriminator column per hierarchy-island. either use the root one, and put all types there, or separate the material from resource in its own subhierarchy. If there is explosion of types, to avoid the huuuge union/outerjoin, u can make the resource a "virtual base", that is, not a table at all - so u'll have two separate db-hierarchies, each one with its own root/discriminator. (dbcook: just declare DBCOOK_no_mapping=True there.) > resource_table = Table( > Column('id',Integer, primary_key=True), > Column('poly', String(31), nullable=False) > ) > > person_table = Table( > Column('id',Integer, primary_key=True, ForeignKey('resource.id'), > primary_key=True)), > Column('poly', String(31), nullable=False) > ) u should not have poly here. its already in the root=resource. > employee_table = Table( > Column('id',Integer, primary_key=True, ForeignKey('person.id'), > primary_key=True)), > ) > > class Resource(object): > pass > class Person(Resource): > pass > class Employee(Person): > pass > > mapper(Resource, resource_table, > polymorphic_on=resource_table.c.poly, > polymorphic_identity='resource' > ) > > mapper(Person, person_table, > polymorphic_on=person_table.c.poly, > inherits=Resource, polymorphic_identity='person' > ) either put the correct polymorphic_on=resource.c.poly, or remove it alltogether, it comes from the inherited base-mapper. > mapper(Employee employee_table, > inherits=Person, polymorphic_identity='employee', > ) svilen --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---