[sqlalchemy] Column anon_1.anon_2 is generated in a select statement

2012-02-28 Thread naktinis
Column anon_1.anon_2 is generated in the following scenario: dbsession.query(FirstThing, FirstThing.moved_by.any(User.id == user_id)).options(joinedload_all('some_property')) query = query.join(SecondThing, SecondThing.first_thing_id == FirstThing.id) query =

Re: [sqlalchemy] Column anon_1.anon_2 is generated in a select statement

2012-02-28 Thread Michael Bayer
On Feb 28, 2012, at 9:40 AM, naktinis wrote: Column anon_1.anon_2 is generated in the following scenario: dbsession.query(FirstThing, FirstThing.moved_by.any(User.id == user_id)).options(joinedload_all('some_property')) query = query.join(SecondThing, SecondThing.first_thing_id ==

Re: [sqlalchemy] Column anon_1.anon_2 is generated in a select statement

2012-02-28 Thread naktinis
I should have pointed out that I got a NoSuchColumnError because of anon_1.anon_2. There is no column anon_2 in any of the tables. It's just an alias name of a derived table. Is table_name_1.table_name_2 supposed to mean anything? On Tuesday, February 28, 2012 5:53:42 PM UTC+2, Michael Bayer

Re: [sqlalchemy] Column anon_1.anon_2 is generated in a select statement

2012-02-28 Thread Michael Bayer
it appears here the anon_2 is a label being given to your otherwise unnamed FirstThing.moved_by.any() call, which is a subquery. you're not showing me the full query being rendered but I would imagine the important bits are: SELECT anon_1.anon_2 AS anon_1_anon_2 FROM (SELECT EXISTS (...)

Re: [sqlalchemy] Column anon_1.anon_2 is generated in a select statement

2012-02-28 Thread Michael Bayer
Here's a test which generates essentially the same form and runs fine, I'll try to simulate more of exactly what you're doing. Or if you had a real test case ready to go, would save me a ton of time. from sqlalchemy import * from sqlalchemy.orm import * from sqlalchemy.ext.declarative import

Re: [sqlalchemy] Column anon_1.anon_2 is generated in a select statement

2012-02-28 Thread Michael Bayer
OK it's another limit + joinedload - subquery targeting issue, so this is http://www.sqlalchemy.org/trac/ticket/2419 and workaround for now is use subqueryload_all() instead of joinedload_all() for this specific query. On Feb 28, 2012, at 11:43 AM, Michael Bayer wrote: Here's a test

Re: [sqlalchemy] Column anon_1.anon_2 is generated in a select statement

2012-02-28 Thread naktinis
Cool! Thanks so much! I'll give the workaround a try. Yes, now I see - anon_2 was a column name, not a table name. On Tuesday, February 28, 2012 6:54:42 PM UTC+2, Michael Bayer wrote: OK it's another limit + joinedload - subquery targeting issue, so this is