[sqlalchemy] Re: Problems with NOT IN and layered subqueries

2009-09-08 Thread Michael Bayer
an example of NOT IN (subquery): from sqlalchemy import * from sqlalchemy.sql import column, table s = select([column(foo)]).select_from(table(bar)).where(~column(foo).in_(select([column(bar)]).select_from(table(bat)).where(column(bar)==5))) print s SELECT foo FROM bar WHERE foo NOT IN

[sqlalchemy] Re: Problems with NOT IN and layered subqueries

2009-09-08 Thread Michael Bayer
Seth wrote: Thank you Michael, What about using this type of thing inside another query? I keep getting: AttributeError: 'Select' object has no attribute '_nested_statement' the identifier '_nested_statement' is not part of SQLAlchemy so that's something on your end (or perhaps you're

[sqlalchemy] Re: Problems with NOT IN and layered subqueries

2009-09-08 Thread Seth
Thank you Michael, What about using this type of thing inside another query? I keep getting: AttributeError: 'Select' object has no attribute '_nested_statement' Seth On Sep 8, 7:16 am, Michael Bayer mike...@zzzcomputing.com wrote: an example of NOT IN (subquery): from sqlalchemy

[sqlalchemy] Re: Problems with NOT IN and layered subqueries

2009-09-08 Thread Michael Bayer
why dont you try: query(Post.id, Post.user_id).from_statement(statement1.union (statement2)) ? On Sep 8, 2009, at 8:27 PM, Seth wrote: Michael, I was using SA 0.5.1. Upgrading to 0.5.5 resolved the AttributeError. I am, however, having one final issue with my query: users =

[sqlalchemy] Re: Problems with NOT IN and layered subqueries

2009-09-08 Thread Seth
Michael, I was using SA 0.5.1. Upgrading to 0.5.5 resolved the AttributeError. I am, however, having one final issue with my query: users = DBSession.query(Post.id.label('post_id'), Post.user_id.label('user_id')).union(Discussion.__table__.select().with_only_columns(['post_id',