]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Include GROUP BY in _should_nest_selectable criteria
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 30 Dec 2019 18:08:17 +0000 (13:08 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 30 Dec 2019 18:17:17 +0000 (13:17 -0500)
commit2d5fa22c7d53ff8109d47ba5ae4fe3b9849ddd09
treeb9d7df7d2b7058420468d76c0f61b38e94640afd
parent9d4a58d35c53484a1de66396139fc34cd65f5be8
Include GROUP BY in _should_nest_selectable criteria

Fixed bug where usage of joined eager loading would not properly wrap the
query inside of a subquery when :meth:`.Query.group_by` were used against
the query.   When any kind of result-limiting approach is used, such as
DISTINCT, LIMIT, OFFSET, joined eager loading embeds the row-limited query
inside of a subquery so that the collection results are not impacted.   For
some reason, the presence of GROUP BY was never included in this criterion,
even though it has a similar effect as using DISTINCT.   Additionally, the
bug would prevent using GROUP BY at all for a joined eager load query for
most database platforms which forbid non-aggregated, non-grouped columns
from being in the query, as the additional columns for the joined eager
load would not be accepted by the database.

Fixes: #5065
Change-Id: I9a2ed8196f83297ec38012138d1a5acdf9e88155
doc/build/changelog/unreleased_13/5065.rst [new file with mode: 0644]
lib/sqlalchemy/orm/query.py
test/orm/test_eager_relations.py
test/orm/test_subquery_relations.py