Replaced QueryWrapper single usage with RawSQL.
This commit is contained in:
parent
8685e764ef
commit
3ca77e2b84
|
@ -30,20 +30,6 @@ def subclasses(cls):
|
||||||
yield from subclasses(subclass)
|
yield from subclasses(subclass)
|
||||||
|
|
||||||
|
|
||||||
class QueryWrapper:
|
|
||||||
"""
|
|
||||||
A type that indicates the contents are an SQL fragment and the associate
|
|
||||||
parameters. Can be used to pass opaque data to a where-clause, for example.
|
|
||||||
"""
|
|
||||||
contains_aggregate = False
|
|
||||||
|
|
||||||
def __init__(self, sql, params):
|
|
||||||
self.data = sql, list(params)
|
|
||||||
|
|
||||||
def as_sql(self, compiler=None, connection=None):
|
|
||||||
return self.data
|
|
||||||
|
|
||||||
|
|
||||||
class Q(tree.Node):
|
class Q(tree.Node):
|
||||||
"""
|
"""
|
||||||
Encapsulate filters as objects that can then be combined logically (using
|
Encapsulate filters as objects that can then be combined logically (using
|
||||||
|
|
|
@ -7,9 +7,7 @@ from django.core.exceptions import EmptyResultSet, FieldError
|
||||||
from django.db.models.constants import LOOKUP_SEP
|
from django.db.models.constants import LOOKUP_SEP
|
||||||
from django.db.models.expressions import OrderBy, Random, RawSQL, Ref, Value
|
from django.db.models.expressions import OrderBy, Random, RawSQL, Ref, Value
|
||||||
from django.db.models.functions import Cast
|
from django.db.models.functions import Cast
|
||||||
from django.db.models.query_utils import (
|
from django.db.models.query_utils import Q, select_related_descend
|
||||||
Q, QueryWrapper, select_related_descend,
|
|
||||||
)
|
|
||||||
from django.db.models.sql.constants import (
|
from django.db.models.sql.constants import (
|
||||||
CURSOR, GET_ITERATOR_CHUNK_SIZE, MULTI, NO_RESULTS, ORDER_DIR, SINGLE,
|
CURSOR, GET_ITERATOR_CHUNK_SIZE, MULTI, NO_RESULTS, ORDER_DIR, SINGLE,
|
||||||
)
|
)
|
||||||
|
@ -1139,7 +1137,7 @@ class SQLCompiler:
|
||||||
lhs_sql, lhs_params = self.compile(select_col)
|
lhs_sql, lhs_params = self.compile(select_col)
|
||||||
rhs = '%s.%s' % (qn(alias), qn2(columns[index]))
|
rhs = '%s.%s' % (qn(alias), qn2(columns[index]))
|
||||||
self.query.where.add(
|
self.query.where.add(
|
||||||
QueryWrapper('%s = %s' % (lhs_sql, rhs), lhs_params), 'AND')
|
RawSQL('%s = %s' % (lhs_sql, rhs), lhs_params), 'AND')
|
||||||
|
|
||||||
sql, params = self.as_sql()
|
sql, params = self.as_sql()
|
||||||
return 'EXISTS (%s)' % sql, params
|
return 'EXISTS (%s)' % sql, params
|
||||||
|
|
Loading…
Reference in New Issue