Great. Thanks!

2008/10/22, Michael Bayer <[EMAIL PROTECTED]>:
>
> I forgot to mention i fixed this for 0.4 + 0.5 in r5180/5181...thanks
> for the test !
>
> On Oct 21, 2008, at 3:48 AM, 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
>>
>> >
>> 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"
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to