]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
- Changed the underlying approach to query.count().
authorMike Bayer <mike_mp@zzzcomputing.com>
Thu, 10 Mar 2011 00:17:45 +0000 (19:17 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Thu, 10 Mar 2011 00:17:45 +0000 (19:17 -0500)
commite7be5a5729cabc6133b4fc83c06f6c5277a7af19
treeacca1e4ff7c5683cbd4ae615bd05fc90062c5b2f
parenta1288bf78f887aeef890e4e6cc0f769f4d6a81f5
- Changed the underlying approach to query.count().
query.count() is now in all cases exactly:

query.
    from_self(func.count(literal_column('1'))).
    scalar()

That is, "select count(1) from (<full query>)".
This produces a subquery in all cases, but
vastly simplifies all the guessing count()
tried to do previously, which would still
fail in many scenarios particularly when
joined table inheritance and other joins
were involved.  If the subquery produced
for an otherwise very simple count is really
an issue, use query(func.count()) as an
optimization.  [ticket:2093]
CHANGES
lib/sqlalchemy/orm/query.py
test/orm/inheritance/test_query.py