summaryrefslogtreecommitdiff
path: root/django/db/models/sql/where.py
diff options
context:
space:
mode:
Diffstat (limited to 'django/db/models/sql/where.py')
-rw-r--r--django/db/models/sql/where.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/django/db/models/sql/where.py b/django/db/models/sql/where.py
index 0ca95f7018..1635a686c2 100644
--- a/django/db/models/sql/where.py
+++ b/django/db/models/sql/where.py
@@ -26,6 +26,7 @@ class WhereNode(tree.Node):
contains_aggregate attribute.
"""
default = AND
+ resolved = False
def split_having(self, negated=False):
"""
@@ -108,7 +109,7 @@ class WhereNode(tree.Node):
# around the inner SQL in the negated case, even if the
# inner SQL contains just a single expression.
sql_string = 'NOT (%s)' % sql_string
- elif len(result) > 1:
+ elif len(result) > 1 or self.resolved:
sql_string = '(%s)' % sql_string
return sql_string, result_params
@@ -181,6 +182,11 @@ class WhereNode(tree.Node):
def is_summary(self):
return any(child.is_summary for child in self.children)
+ def resolve_expression(self, *args, **kwargs):
+ clone = self.clone()
+ clone.resolved = True
+ return clone
+
class NothingNode:
"""A node that matches nothing."""