diff options
author | Simon Charette <charette.s@gmail.com> | 2023-04-21 23:10:15 -0400 |
---|---|---|
committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2023-04-24 08:32:49 +0200 |
commit | 83c9765f45e4622e4a5af3adcd92263a28b13624 (patch) | |
tree | 5a04874efd06b5e6a12a5c95ef9c5e4bbc2300e5 /django/db/models/sql/query.py | |
parent | 1a13161eab2d040990734f80b3eedea354f6a4ba (diff) | |
download | django-83c9765f45e4622e4a5af3adcd92263a28b13624.tar.gz |
Refs #33766 -- Removed sql.Query.build_filtered_relation_q().
It was a copy of sql.Query._add_q that avoided JOIN updates.
Diffstat (limited to 'django/db/models/sql/query.py')
-rw-r--r-- | django/db/models/sql/query.py | 37 |
1 files changed, 8 insertions, 29 deletions
diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py index 24e08ae6a6..c8f849daea 100644 --- a/django/db/models/sql/query.py +++ b/django/db/models/sql/query.py @@ -1347,6 +1347,7 @@ class Query(BaseExpression): split_subq=True, check_filterable=True, summarize=False, + update_join_types=True, ): """ Build a WhereNode for a single filter clause but don't add it @@ -1385,6 +1386,7 @@ class Query(BaseExpression): split_subq=split_subq, check_filterable=check_filterable, summarize=summarize, + update_join_types=update_join_types, ) if hasattr(filter_expr, "resolve_expression"): if not getattr(filter_expr, "conditional", False): @@ -1537,6 +1539,7 @@ class Query(BaseExpression): split_subq=True, check_filterable=True, summarize=False, + update_join_types=True, ): """Add a Q-object to the current filter.""" connector = q_object.connector @@ -1556,41 +1559,17 @@ class Query(BaseExpression): split_subq=split_subq, check_filterable=check_filterable, summarize=summarize, + update_join_types=update_join_types, ) joinpromoter.add_votes(needed_inner) if child_clause: target_clause.add(child_clause, connector) - needed_inner = joinpromoter.update_join_types(self) + if update_join_types: + needed_inner = joinpromoter.update_join_types(self) + else: + needed_inner = [] return target_clause, needed_inner - def build_filtered_relation_q( - self, q_object, reuse, branch_negated=False, current_negated=False - ): - """Add a FilteredRelation object to the current filter.""" - connector = q_object.connector - current_negated ^= q_object.negated - branch_negated = branch_negated or q_object.negated - target_clause = WhereNode(connector=connector, negated=q_object.negated) - for child in q_object.children: - if isinstance(child, Node): - child_clause = self.build_filtered_relation_q( - child, - reuse=reuse, - branch_negated=branch_negated, - current_negated=current_negated, - ) - else: - child_clause, _ = self.build_filter( - child, - can_reuse=reuse, - branch_negated=branch_negated, - current_negated=current_negated, - allow_joins=True, - split_subq=False, - ) - target_clause.add(child_clause, connector) - return target_clause - def add_filtered_relation(self, filtered_relation, alias): filtered_relation.alias = alias lookups = dict(get_children_from_q(filtered_relation.condition)) |