diff options
| author | Sergey Fedoseev <fedoseev.sergey@gmail.com> | 2017-12-02 07:48:49 +0500 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2017-12-01 21:48:49 -0500 |
| commit | cf12257db23fa248c89a3da3f718aa01a50ca659 (patch) | |
| tree | fb01b1c49bc46c87c9cd67eb30b280f8cb665774 /django/db/models/sql | |
| parent | c3e0adcad8d8ba94b33cabd137056166ed36dae0 (diff) | |
Fixed #28863 -- Fixed filter on annotation that contains Q.
Diffstat (limited to 'django/db/models/sql')
| -rw-r--r-- | django/db/models/sql/where.py | 8 |
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.""" |
