summaryrefslogtreecommitdiff
path: root/django/db/models/sql/where.py
diff options
context:
space:
mode:
authorJosh Smeaton <josh.smeaton@gmail.com>2017-01-17 02:03:15 +1100
committerTim Graham <timograham@gmail.com>2017-01-16 10:03:15 -0500
commit1df89a60c5b7a28d7fda4c9ba7c07f02fd7de0fa (patch)
tree682ee02fb33cc654803d37b46b65dc38f32d506e /django/db/models/sql/where.py
parentf2d2f178965584a1ebe666a6621ef82581233fab (diff)
Fixed #25307 -- Fixed QuerySet.annotate() crash with conditional expressions.
Thanks Travis Newport for the tests and Josh Smeaton for contributing to the patch.
Diffstat (limited to 'django/db/models/sql/where.py')
-rw-r--r--django/db/models/sql/where.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/django/db/models/sql/where.py b/django/db/models/sql/where.py
index df44803b8a..bb4e9252b4 100644
--- a/django/db/models/sql/where.py
+++ b/django/db/models/sql/where.py
@@ -118,6 +118,13 @@ class WhereNode(tree.Node):
cols.extend(child.get_group_by_cols())
return cols
+ def get_source_expressions(self):
+ return self.children[:]
+
+ def set_source_expressions(self, children):
+ assert len(children) == len(self.children)
+ self.children = children
+
def relabel_aliases(self, change_map):
"""
Relabels the alias values of any children. 'change_map' is a dictionary
@@ -160,6 +167,10 @@ class WhereNode(tree.Node):
def contains_aggregate(self):
return self._contains_aggregate(self)
+ @property
+ def is_summary(self):
+ return any(child.is_summary for child in self.children)
+
class NothingNode(object):
"""