summaryrefslogtreecommitdiff
path: root/django/db/models/sql/where.py
diff options
context:
space:
mode:
authorDavid Sanders <shang.xiao.sanders@gmail.com>2022-09-24 00:15:03 +1000
committerGitHub <noreply@github.com>2022-09-23 15:15:03 +0100
commit1674c70525bc370132a1db27617e468081920d11 (patch)
tree9536f8ecea5faf9747e13380c793174e3e519b1a /django/db/models/sql/where.py
parent37a13cc92d51d5a57b42240b9a5dd250648efa24 (diff)
Fixed #34024 -- Fixed crash when aggregating querysets with Q objects annotations.
This reverts b64db05b9cedd96905d637a2d824cbbf428e40e7. It was reasonable to assume it was unnecessary code as there were no failing tests upon its removal. This commit adds the necessary regression tests for the failing condition identified in #34024 alongside the original tests added in the PR for which WhereNode.is_summary was introduced.
Diffstat (limited to 'django/db/models/sql/where.py')
-rw-r--r--django/db/models/sql/where.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/django/db/models/sql/where.py b/django/db/models/sql/where.py
index e2af46a309..5ce7e4e55c 100644
--- a/django/db/models/sql/where.py
+++ b/django/db/models/sql/where.py
@@ -244,6 +244,10 @@ class WhereNode(tree.Node):
def contains_over_clause(self):
return self._contains_over_clause(self)
+ @property
+ def is_summary(self):
+ return any(child.is_summary for child in self.children)
+
@staticmethod
def _resolve_leaf(expr, query, *args, **kwargs):
if hasattr(expr, "resolve_expression"):