summaryrefslogtreecommitdiff
path: root/django/db/models/sql/where.py
diff options
context:
space:
mode:
authorSimon Charette <charette.s@gmail.com>2022-11-06 00:28:33 -0400
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2022-11-09 13:22:14 +0100
commit59bea9efd2768102fc9d3aedda469502c218e9b7 (patch)
treea32b9531c0adfd1bb7ce5a9177c33b7e33101ddd /django/db/models/sql/where.py
parent321ecb40f4da842926e1bc07e11df4aabe53ca4b (diff)
Fixed #28477 -- Stripped unused annotations on aggregation.
Also avoid an unnecessary pushdown when aggregating over a query that doesn't have aggregate annotations.
Diffstat (limited to 'django/db/models/sql/where.py')
-rw-r--r--django/db/models/sql/where.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/django/db/models/sql/where.py b/django/db/models/sql/where.py
index 1928ba91b8..aaab1730b7 100644
--- a/django/db/models/sql/where.py
+++ b/django/db/models/sql/where.py
@@ -227,6 +227,12 @@ class WhereNode(tree.Node):
clone.children.append(child.replace_expressions(replacements))
return clone
+ def get_refs(self):
+ refs = set()
+ for child in self.children:
+ refs |= child.get_refs()
+ return refs
+
@classmethod
def _contains_aggregate(cls, obj):
if isinstance(obj, tree.Node):