Excluding a column form Query result

2,175 views
Skip to first unread message

Jurie-Jan Botha

unread,
Dec 6, 2010, 1:50:28 AM12/6/10
to sqlalchemy
Is there a way to add a column to a Query object to be used elsewhere
in the query, but prevent it from being listed in the result of the
Query?

Michael Bayer

unread,
Dec 6, 2010, 3:42:49 PM12/6/10
to sqlal...@googlegroups.com
columns participate in the SQL rendition of a query as they are used within the filter(), group_by(), order_by(), and other similar generative methods on Query. There is no additional step needed.

If the columns are owned by a table that is not currently participating in the query, the owning table is added automatically to the FROM clause of the rendered SQL. It is the user's responsibility to ensure that this new table is appropriately joined to the existing tables of the query, either through the usage of filter() to equate common columns together, or via the usage of join(). See the examples in http://www.sqlalchemy.org/docs/orm/tutorial.html?highlight=joins#querying-with-joins .

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

Reply all
Reply to author
Forward
0 new messages