probably a bug as well, ticket #853 added. though i would comment that what youre trying to do there is quite exotic.
On Nov 6, 2007, at 10:33 AM, klaus wrote: > rom sqlalchemy import * > from sqlalchemy.orm import * > > metadata = MetaData("...") > metadata.bind.echo=True > > table = Table("test", metadata, > Column("id", Integer, primary_key=True), > Column("data", String)) > > table.create() > > table.insert().execute([{"data": 1}, {"data": 2}, {"data": 3}, > {"data": 4}, {"data": 5}, {"data": 6}, > {"data": 7}, {"data": 8}, {"data": 9}, > {"data": 10}, {"data": 11}, {"data": 12}, > {"data": 13}, {"data": 14}, {"data": 15}, > {"data": 30}, {"data": 44}, {"data": 55}]) > > test = table.select(table.c.id.in_([2, 3, 4, 5, 8, 10, 11, 13, 30, 44, > 45])).alias("testView") > > class Test(object): > pass > > mapper(Test, test) > > referer = Table("referer", metadata, > Column("id", Integer, primary_key=True), > Column("fk", Integer, ForeignKey("test.id"))) > > referer.create() > > referer.insert().execute([{"fk": 2}]) > > class Referer(object): > pass > > mapper(Referer, referer, properties={"ref": relation(Test)}) > > session = create_session() > > t = session.query(Test).get(2) > print t > r = session.query(Referer).get(1) > print r.fk, r.ref > > > It prints > > None > 2 None > > and the SQL statement for the first get should have param_1=1 instead > of None. > > 2007-11-06 16:26:30,394 INFO sqlalchemy.engine.base.Engine.0x..34 > SELECT "testView".id AS "testView_id", "testView".data AS > "testView_data" > FROM (SELECT test.id AS id, test.data AS data > FROM test > WHERE test.id IN (%(test_id)s, %(test_id_1)s, %(test_id_2)s, % > (test_id_3)s, %(test_id_4)s, %(test_id_5)s, %(test_id_6)s, % > (test_id_7)s, %(test_id_8)s, %(test_id_9)s, %(test_id_10)s)) AS > "testView" > WHERE "testView".id = %(param_1)s ORDER BY "testView".id > 2007-11-06 16:26:30,394 INFO sqlalchemy.engine.base.Engine.0x..34 > {'test_id_3': 5, 'test_id_10': 45, 'param_1': None, 'test_id_8': 30, > 'test_id_9': 44, 'test_id_1': 3, 'test_id_2': 4, 'test_id': 2, > 'test_id_4': 8, 'test_id_5': 10, 'test_id_6': 11, 'test_id_7': 13} --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---