On Feb 23, 2010, at 5:23 PM, David Bolen wrote:

> But various attempts to use these queries in a filter() portion of the
> original query always result ArgumentError exception that "filter()
> argument must be of type sqlalchemy.sql.ClauseElement or string"
> 
> I figured I'm missing some magic method to permit turning "att == reg"
> into a ClauseElemnt somehow, but my attempts so far haven't worked.  So
> for the moment I'm supplying the additional sub-query clause as pure
> text.

if the issue is that you have a query(), and you like to say somequery.filter(q 
== "x"), you'd turn query() into a "subquery" (i.e. an alisaed SQLAlchemy 
expression object) using q.subquery(), and then into a "scalar" subquery using 
as_scalar(), which means the select() construct now behaves like a column.  
as_scalar() is also available directly on a select() construct.

some background on as_scalar() is presented from the SQL expression side of 
things at http://www.sqlalchemy.org/docs/sqlexpression.html#scalar-selects .



-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to