summaryrefslogtreecommitdiff
path: root/django/db/models/sql/query.py
diff options
context:
space:
mode:
authorNick Pope <nick@nickpope.me.uk>2021-07-20 20:38:17 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2021-07-22 08:49:20 +0200
commitc35b81b864ffa84751bac7d73046840f576491f9 (patch)
tree2cabe599d59584591e90e55f06ce6bfd66978348 /django/db/models/sql/query.py
parent012f38f9594b35743e9ab231757b7b62db638323 (diff)
Fixed #32951 -- Removed Query.where_class & co.
Unused since 3caf957ed5eaa831a485abcb89f27266dbf3e82b.
Diffstat (limited to 'django/db/models/sql/query.py')
-rw-r--r--django/db/models/sql/query.py22
1 files changed, 11 insertions, 11 deletions
diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py
index af5f684943..8ecac4a3b7 100644
--- a/django/db/models/sql/query.py
+++ b/django/db/models/sql/query.py
@@ -144,7 +144,7 @@ class Query(BaseExpression):
compiler = 'SQLCompiler'
- def __init__(self, model, where=WhereNode, alias_cols=True):
+ def __init__(self, model, alias_cols=True):
self.model = model
self.alias_refcount = {}
# alias_map is the most important data structure regarding joins.
@@ -175,8 +175,7 @@ class Query(BaseExpression):
# clause to contain other than default fields (values(), subqueries...)
# Note that annotations go to annotations dictionary.
self.select = ()
- self.where = where()
- self.where_class = where
+ self.where = WhereNode()
# The group_by attribute can have one of the following forms:
# - None: no group by at all in the query
# - A tuple of expressions: group by (at least) those expressions.
@@ -1265,7 +1264,7 @@ class Query(BaseExpression):
condition = filter_expr.resolve_expression(self, allow_joins=allow_joins)
if not isinstance(condition, Lookup):
condition = self.build_lookup(['exact'], condition, True)
- return self.where_class([condition], connector=AND), []
+ return WhereNode([condition], connector=AND), []
arg, value = filter_expr
if not arg:
raise FieldError("Cannot parse keyword query %r" % arg)
@@ -1286,7 +1285,7 @@ class Query(BaseExpression):
if reffed_expression:
condition = self.build_lookup(lookups, reffed_expression, value)
- return self.where_class([condition], connector=AND), []
+ return WhereNode([condition], connector=AND), []
opts = self.get_meta()
alias = self.get_initial_alias()
@@ -1329,7 +1328,7 @@ class Query(BaseExpression):
condition = self.build_lookup(lookups, col, value)
lookup_type = condition.lookup_name
- clause = self.where_class([condition], connector=AND)
+ clause = WhereNode([condition], connector=AND)
require_outer = lookup_type == 'isnull' and condition.rhs is True and not current_negated
if current_negated and (lookup_type != 'isnull' or condition.rhs is False) and condition.rhs is not None:
@@ -1381,6 +1380,9 @@ class Query(BaseExpression):
def build_where(self, filter_expr):
return self.build_filter(filter_expr, allow_joins=False)[0]
+ def clear_where(self):
+ self.where = WhereNode()
+
def _add_q(self, q_object, used_aliases, branch_negated=False,
current_negated=False, allow_joins=True, split_subq=True,
check_filterable=True):
@@ -1388,8 +1390,7 @@ class Query(BaseExpression):
connector = q_object.connector
current_negated = current_negated ^ q_object.negated
branch_negated = branch_negated or q_object.negated
- target_clause = self.where_class(connector=connector,
- negated=q_object.negated)
+ target_clause = WhereNode(connector=connector, negated=q_object.negated)
joinpromoter = JoinPromoter(q_object.connector, len(q_object.children), current_negated)
for child in q_object.children:
child_clause, needed_inner = self.build_filter(
@@ -1408,7 +1409,7 @@ class Query(BaseExpression):
connector = q_object.connector
current_negated ^= q_object.negated
branch_negated = branch_negated or q_object.negated
- target_clause = self.where_class(connector=connector, negated=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(
@@ -2301,8 +2302,7 @@ class Query(BaseExpression):
select_fields = [r[0] for r in join_field.related_fields]
select_alias = lookup_tables[trimmed_paths + 1]
self.unref_alias(lookup_tables[trimmed_paths])
- extra_restriction = join_field.get_extra_restriction(
- self.where_class, None, lookup_tables[trimmed_paths + 1])
+ extra_restriction = join_field.get_extra_restriction(None, lookup_tables[trimmed_paths + 1])
if extra_restriction:
self.where.add(extra_restriction, AND)
else: