summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2019-12-30 13:08:17 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2019-12-30 13:17:17 -0500
commit2d5fa22c7d53ff8109d47ba5ae4fe3b9849ddd09 (patch)
treeb9d7df7d2b7058420468d76c0f61b38e94640afd /lib/sqlalchemy
parent9d4a58d35c53484a1de66396139fc34cd65f5be8 (diff)
downloadsqlalchemy-2d5fa22c7d53ff8109d47ba5ae4fe3b9849ddd09.tar.gz
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
Diffstat (limited to 'lib/sqlalchemy')
-rw-r--r--lib/sqlalchemy/orm/query.py1
1 files changed, 1 insertions, 0 deletions
diff --git a/lib/sqlalchemy/orm/query.py b/lib/sqlalchemy/orm/query.py
index 80d544068..22e24be84 100644
--- a/lib/sqlalchemy/orm/query.py
+++ b/lib/sqlalchemy/orm/query.py
@@ -3479,6 +3479,7 @@ class Query(Generative):
kwargs.get("limit") is not None
or kwargs.get("offset") is not None
or kwargs.get("distinct", False)
+ or kwargs.get("group_by", False)
)
def exists(self):