Hello, all,

I have a question that I discovered while troubleshooting a problem with our 
application today: It seems that joinedload options (e.g., 
http://docs.sqlalchemy.org/en/rel_0_9/orm/loading.html?highlight=joinedload_all#sqlalchemy.orm.joinedload)
 on a query do not affect the query that is emitted when you do a 
query.count(); the following illustrates my point:

# ...query has already been constructed, and includes .options(joinedload(...))
count = query.count()         # line 1
results = query.all()         # line 2
assert count == len(results)  # fails!

Upon inspection of the queries emitted by line 1 and line 2, the joinedload()ed 
relationship's table is included in the query emitted by line 2 (correctly), 
but is not included in the query emitted for the count by line 1 
(surprisingly!). In our case, because the joinedload()ed relationship happens 
to add rows to the result set of the query, the count (line 1) and the length 
(line 2) of the results do not match!

Can someone confirm that this is expected behavior? If so, is there an 
explanation for this behavior?

Thanks in advance for your time and reply,
Mike

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to