mirror of https://github.com/django/django.git
Refs #16187 -- Stopped compiling query compilers during lookup rhs processing.
Lookup right hand side processing was compiling query compilers which happened to work by chance as SQLCompiler defines a as_sql() method with two optional parameters albeit it doesn't expect the same type of arguments.
This commit is contained in:
parent
75aeebebfe
commit
9ae4362bec
|
@ -89,12 +89,6 @@ class Lookup:
|
|||
value = Value(value, output_field=self.lhs.output_field)
|
||||
value = self.apply_bilateral_transforms(value)
|
||||
value = value.resolve_expression(compiler.query)
|
||||
# Due to historical reasons there are a couple of different
|
||||
# ways to produce sql here. get_compiler is likely a Query
|
||||
# instance and as_sql just something with as_sql. Finally the value
|
||||
# can of course be just plain Python value.
|
||||
if hasattr(value, 'get_compiler'):
|
||||
value = value.get_compiler(connection=connection)
|
||||
if hasattr(value, 'as_sql'):
|
||||
sql, params = compiler.compile(value)
|
||||
return '(' + sql + ')', params
|
||||
|
|
|
@ -989,6 +989,9 @@ class Query:
|
|||
clone.clear_ordering(True)
|
||||
return clone
|
||||
|
||||
def as_sql(self, compiler, connection):
|
||||
return self.get_compiler(connection=connection).as_sql()
|
||||
|
||||
def prepare_lookup_value(self, value, lookups, can_reuse, allow_joins=True):
|
||||
# Default lookup if none given is exact.
|
||||
used_joins = []
|
||||
|
|
Loading…
Reference in New Issue