On Wed, Mar 18, 2009 at 11:00 AM, Michael Bayer <[email protected]>wrote:

>
> Sanjay wrote:
> >
> > Hi,
> >
> > I want to write something like
> >
> > query.filter(BizObj.col.in_("SELECT col FROM some_table")).
> >
> > Could not find out how to do it. The code on neither the above nor the
> > below worked.
> >
> > query.filter(BizObj.col1.in_(sqlalchemy.sql.text("SELECT col1 FROM
> > sometable"))).
>
>
> in_() is going to want a select() construct for that calling style.  if
> you don't have a Table or mapped class for "sometable", you can make an
> ad-hoc table using table():
>
> from sqlalchemy.sql import table, column
>
> BizObj.col1.in_(select([table("sometable", column("col1")).c.col1]))
>
>
and if I do have a mapped class, say SomeClass, is there an ORM-like syntax
to use  the class or do I drop into SQL-like syntax using
SomeClass.__table__ ?

query = session.query(BizObj).filter(BizObj.col1.in_(??????))

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

Reply via email to