diff options
| author | Keryn Knight <keryn@kerynknight.com> | 2021-07-17 21:54:36 +0100 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2021-07-28 09:38:42 +0200 |
| commit | 5b8ef8aa5b746d96d6558efd6bc119f347002703 (patch) | |
| tree | 7bc74c504e65c57cdb0311a63984ae39c2115124 /django/db/models/sql/query.py | |
| parent | 5fee36973cc3a8f74b04f500264e3f5831f781aa (diff) | |
Refs #32946 -- Changed Query.add_filter() to take two arguments.
Diffstat (limited to 'django/db/models/sql/query.py')
| -rw-r--r-- | django/db/models/sql/query.py | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py index 8ecac4a3b7..181d4419fa 100644 --- a/django/db/models/sql/query.py +++ b/django/db/models/sql/query.py @@ -1357,8 +1357,8 @@ class Query(BaseExpression): clause.add(lookup_class(value, False), AND) return clause, used_joins if not require_outer else () - def add_filter(self, filter_clause): - self.add_q(Q(**{filter_clause[0]: filter_clause[1]})) + def add_filter(self, filter_lhs, filter_rhs): + self.add_q(Q((filter_lhs, filter_rhs))) def add_q(self, q_object): """ @@ -1762,15 +1762,15 @@ class Query(BaseExpression): LIMIT 1 ) """ - filter_lhs, filter_rhs = filter_expr - if isinstance(filter_rhs, OuterRef): - filter_expr = (filter_lhs, OuterRef(filter_rhs)) - elif isinstance(filter_rhs, F): - filter_expr = (filter_lhs, OuterRef(filter_rhs.name)) # Generate the inner query. query = Query(self.model) query._filtered_relations = self._filtered_relations - query.add_filter(filter_expr) + filter_lhs, filter_rhs = filter_expr + if isinstance(filter_rhs, OuterRef): + filter_rhs = OuterRef(filter_rhs) + elif isinstance(filter_rhs, F): + filter_rhs = OuterRef(filter_rhs.name) + query.add_filter(filter_lhs, filter_rhs) query.clear_ordering(force=True) # Try to have as simple as possible subquery -> trim leading joins from # the subquery. |
