summaryrefslogtreecommitdiff
path: root/django/db/models/sql
diff options
context:
space:
mode:
authorNick Pope <nick@nickpope.me.uk>2022-07-23 13:31:35 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2022-07-27 07:55:09 +0200
commit769d7cce4aedfcbba59f1b68577225d07701c206 (patch)
treec896675140b6d356bf35db97df06b9d83dad67f5 /django/db/models/sql
parente20e5d1557785ba71e8ef0ceb8ccb85bdc13840a (diff)
Used AND, OR, XOR constants instead of hard-coded values.
Diffstat (limited to 'django/db/models/sql')
-rw-r--r--django/db/models/sql/compiler.py3
-rw-r--r--django/db/models/sql/query.py6
2 files changed, 5 insertions, 4 deletions
diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py
index 461e1ae156..cfac22a019 100644
--- a/django/db/models/sql/compiler.py
+++ b/django/db/models/sql/compiler.py
@@ -19,6 +19,7 @@ from django.db.models.sql.constants import (
SINGLE,
)
from django.db.models.sql.query import Query, get_order_dir
+from django.db.models.sql.where import AND
from django.db.transaction import TransactionManagementError
from django.utils.functional import cached_property
from django.utils.hashable import make_hashable
@@ -1435,7 +1436,7 @@ class SQLCompiler:
for index, select_col in enumerate(self.query.select):
lhs_sql, lhs_params = self.compile(select_col)
rhs = "%s.%s" % (qn(alias), qn2(columns[index]))
- self.query.where.add(RawSQL("%s = %s" % (lhs_sql, rhs), lhs_params), "AND")
+ self.query.where.add(RawSQL("%s = %s" % (lhs_sql, rhs), lhs_params), AND)
sql, params = self.as_sql()
return "EXISTS (%s)" % sql, params
diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py
index cf7566d771..14ed0c0a63 100644
--- a/django/db/models/sql/query.py
+++ b/django/db/models/sql/query.py
@@ -2658,7 +2658,7 @@ class JoinPromoter:
# to rel_a would remove a valid match from the query. So, we need
# to promote any existing INNER to LOUTER (it is possible this
# promotion in turn will be demoted later on).
- if self.effective_connector == "OR" and votes < self.num_children:
+ if self.effective_connector == OR and votes < self.num_children:
to_promote.add(table)
# If connector is AND and there is a filter that can match only
# when there is a joinable row, then use INNER. For example, in
@@ -2670,8 +2670,8 @@ class JoinPromoter:
# (rel_a__col__icontains=Alex | rel_a__col__icontains=Russell)
# then if rel_a doesn't produce any rows, the whole condition
# can't match. Hence we can safely use INNER join.
- if self.effective_connector == "AND" or (
- self.effective_connector == "OR" and votes == self.num_children
+ if self.effective_connector == AND or (
+ self.effective_connector == OR and votes == self.num_children
):
to_demote.add(table)
# Finally, what happens in cases where we have: