concrete polymorphism with good deal of inheritance and same-keys does not work in current SA. there's no way to differ between X.id=1 and Y.id=1 in the polymunion. there were ideas to add some type-discriminator in the union's primary key, and use that in the machinery, but AFAIK no much is done. my set of concrete-inh testcases still fails in same ways as before (i think there is one more failing since 0.5) Mike will know better.
On Tuesday 21 October 2008 10:48:02 Eric Lemoine wrote: > On Mon, Oct 20, 2008 at 7:46 PM, Michael Bayer <[EMAIL PROTECTED]> wrote: > > its not a known issue but sounds like a bug. a very concise > > test case which we can use as a unit test would help here. > > I hope this is good enough: > > > > from sqlalchemy import * > from sqlalchemy.orm import * > > engine = create_engine('sqlite://', echo=True) > metadata =MetaData(engine) > Session = scoped_session(sessionmaker(bind=engine)) > > refugees_table = Table('refugee', metadata, > Column('refugee_fid', Integer, primary_key=True), > Column('refugee_name', Unicode, key='name')) > > offices_table = Table('office', metadata, > Column('office_fid', Integer, primary_key=True), > Column('office_name', Unicode, key='name')) > > pjoin = polymorphic_union({ > 'refugee': refugees_table, > 'office': offices_table > }, 'type', 'pjoin') > > metadata.create_all() > > class Location(object): > pass > > class Refugee(Location): > pass > > class Office(Location): > pass > > location_mapper = mapper(Location, pjoin, > polymorphic_on=pjoin.c.type, polymorphic_identity='location') > refugee_mapper = mapper(Refugee, refugees_table, > inherits=location_mapper, concrete=True, > polymorphic_identity='refugee') office_mapper = mapper(Office, > offices_table, inherits=location_mapper, concrete=True, > polymorphic_identity='office') > > engine.execute("insert into refugee values(1, \"refugee1\")") > engine.execute("insert into refugee values(2, \"refugee2\")") > engine.execute("insert into office values(1, \"office1\")") > engine.execute("insert into office values(2, \"office2\")") > > # these two pass, good! > assert Session.query(Refugee).get(1).name == "refugee1" > assert Session.query(Refugee).get(2).name == "refugee2" > > #assert Session.query(Office).get(1).office_name == "office1" > #assert Session.query(Office).get(2).office_name == "office2" > > # these two fail, bad! > assert Session.query(Office).get(1).name == "office1" > assert Session.query(Office).get(2).name == "office2" > > -- > Eric > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---