On Aug 27, 1:24 pm, Bryan <bryanv...@gmail.com> wrote:
> I am writing a function that adds particular columns and groupings to
> a query based on some options.  I am trying to write some unit tests
> for the function, and would like to check that the correct columns are
> being added/grouped.
>
> Give a query like:
>
> q = session.query(Employee.firstName, Employee.lastName)
>
> How can I check later that the query object has included
> Employee.firstName in the output columns?

for output columns, we have recently added a method for this purpose
as of version 0.6.3:

http://www.sqlalchemy.org/docs/reference/orm/query.html#sqlalchemy.orm.query.Query.column_descriptions

I'm using it successfully in a library that converts Query objects
into Excel spreadsheets with xlwt.

> Similarly, how can I check, for instance, that the query object is
> grouping on Employee.lastName?

stuff like that is semi-private but relatively stable, most are
available by names like query._group_by, query._order_by,
query._criterion.  If you look at the top of the Query class (the
source), they are all defaulted at the class level.

Semi-private because I really don't want to push things like that to
be first class accessors until we are super certain nothing is
changing there.

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