summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorSimon Charette <charette.s@gmail.com>2019-02-27 00:48:41 -0500
committerTim Graham <timograham@gmail.com>2019-03-21 18:48:41 -0400
commitfb3f034f1c63160c0ff13c609acd01c18be12f80 (patch)
treeea5948f50d2494abedf739a71f62246bb5f9d4ec /django
parent9dc367dc10594ad024c83d398a8e3c3f8f221446 (diff)
Fixed #30158 -- Avoided unnecessary subquery group by on aggregation.
Subquery annotations can be omitted from the GROUP BY clause on aggregation as long as they are not explicitly grouped against. Thanks Jonny Fuller for the report.
Diffstat (limited to 'django')
-rw-r--r--django/db/models/expressions.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/django/db/models/expressions.py b/django/db/models/expressions.py
index 30c2f465f0..cb50f73f1d 100644
--- a/django/db/models/expressions.py
+++ b/django/db/models/expressions.py
@@ -1082,6 +1082,11 @@ class Subquery(Expression):
return clone
return self
+ def get_group_by_cols(self, alias=None):
+ if alias:
+ return [Ref(alias, self)]
+ return []
+
class Exists(Subquery):
template = 'EXISTS(%(subquery)s)'