This is strange. I had problems reproducing the bug for a long time
and was now quite happy that I succeeded.
Yes, I'm using PostgreSQL 8.1.5 and psycopg2. And I still see the
behavior that I reported. That should narrow the problem down to
something in my local setup... I'm sorry for wasting your time.
Klaus
On 7 Nov., 01:00, Michael Bayer <[EMAIL PROTECTED]> wrote:
> I cant reproduce this one. I see you have named bind params so I
> tried with postgres. it also works with sqlite. works with release
> 0.4.0 as well as the trunk. output is (with echoing):
>
> 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 18:57:05,087 INFO sqlalchemy.engine.base.Engine.0x..b0
> {'test_id_3': 5, 'test_id_10': 45, 'param_1': 2, '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}
> <__main__.Test object at 0xc4e610>
> 2007-11-06 18:57:05,090 INFO sqlalchemy.engine.base.Engine.0x..b0
> SELECT referer.id AS referer_id, referer.fk AS referer_fk
> FROM referer
> WHERE referer.id = %(param_1)s ORDER BY referer.id
> 2007-11-06 18:57:05,090 INFO sqlalchemy.engine.base.Engine.0x..b0
> {'param_1': 1}
> 2 <__main__.Test object at 0xc4e610>
>
> try coming up with a reproducing test case and reopen ticket #853 if
> you can come up with it.
>
> On Nov 6, 2007, at 10:33 AM, klaus wrote:
>
>
>
> > Hi all,
> > the following mapped select results in the wrong query. The problem
> > seems to be related to the number of values in a list passed to in_
> > and maybe to "holes" in the list of chosen values.
>
> > from 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}
>
> > Best regards
> > Klaus
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---