]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Move enable_eagerloads(False) out of _from_self() into count()
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 16 Mar 2021 00:01:23 +0000 (20:01 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 16 Mar 2021 00:05:26 +0000 (20:05 -0400)
commit1c5ec1e60999516c016e0fab60979f63060d0a0d
tree30e12bd86cab559a744abe2771f1c5aa0d68fa05
parent0d3dded1a38344a911a627b6a3f32515cce4223f
Move enable_eagerloads(False) out of _from_self() into count()

Fixed regression where calling upon :meth:`_orm.Query.count` in conjunction
with a loader option such as :func:`_orm.joinedload` would fail to ignore
the loader option. This is a behavior that has always been very specific to
the :meth:`_orm.Query.count` method; an error is normally raised if a given
:class:`_orm.Query` has options that don't apply to what it is returning.

Specifically, the call to enable_eagerloads(False) inside of
_from_self() is not needed as loader options are now not invoked
for subqueries.  Instead, set enable_eagerloads(False) in the
count() method itself, so that these options won't be considered
in this specific case.

Fixes: #6052
Change-Id: I0059ed3fb06156ef4116fd015cbef6f89808e8ef
lib/sqlalchemy/orm/query.py
test/orm/test_query.py