Removed obsolete Lookup hook to prepare rhs expressions.
After 3a505c70e7
, all _prepare() methods
return self.
This commit is contained in:
parent
3a505c70e7
commit
5935a9aead
|
@ -240,8 +240,7 @@ class ArrayLenTransform(Transform):
|
||||||
class ArrayInLookup(In):
|
class ArrayInLookup(In):
|
||||||
def get_prep_lookup(self):
|
def get_prep_lookup(self):
|
||||||
values = super().get_prep_lookup()
|
values = super().get_prep_lookup()
|
||||||
if hasattr(self.rhs, '_prepare'):
|
if hasattr(values, 'resolve_expression'):
|
||||||
# Subqueries don't need further preparation.
|
|
||||||
return values
|
return values
|
||||||
# In.process_rhs() expects values to be hashable, so convert lists
|
# In.process_rhs() expects values to be hashable, so convert lists
|
||||||
# to tuples.
|
# to tuples.
|
||||||
|
|
|
@ -245,10 +245,6 @@ class BaseExpression:
|
||||||
])
|
])
|
||||||
return c
|
return c
|
||||||
|
|
||||||
def _prepare(self, field):
|
|
||||||
"""Hook used by Lookup.get_prep_lookup() to do custom preparation."""
|
|
||||||
return self
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def field(self):
|
def field(self):
|
||||||
return self.output_field
|
return self.output_field
|
||||||
|
@ -537,9 +533,6 @@ class ResolvedOuterRef(F):
|
||||||
'only be used in a subquery.'
|
'only be used in a subquery.'
|
||||||
)
|
)
|
||||||
|
|
||||||
def _prepare(self, output_field=None):
|
|
||||||
return self
|
|
||||||
|
|
||||||
def relabeled_clone(self, relabels):
|
def relabeled_clone(self, relabels):
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
@ -551,9 +544,6 @@ class OuterRef(F):
|
||||||
return self.name
|
return self.name
|
||||||
return ResolvedOuterRef(self.name)
|
return ResolvedOuterRef(self.name)
|
||||||
|
|
||||||
def _prepare(self, output_field=None):
|
|
||||||
return self
|
|
||||||
|
|
||||||
|
|
||||||
class Func(SQLiteNumericMixin, Expression):
|
class Func(SQLiteNumericMixin, Expression):
|
||||||
"""An SQL function call."""
|
"""An SQL function call."""
|
||||||
|
|
|
@ -64,8 +64,8 @@ class Lookup:
|
||||||
self.lhs, self.rhs = new_exprs
|
self.lhs, self.rhs = new_exprs
|
||||||
|
|
||||||
def get_prep_lookup(self):
|
def get_prep_lookup(self):
|
||||||
if hasattr(self.rhs, '_prepare'):
|
if hasattr(self.rhs, 'resolve_expression'):
|
||||||
return self.rhs._prepare(self.lhs.output_field)
|
return self.rhs
|
||||||
if self.prepare_rhs and hasattr(self.lhs.output_field, 'get_prep_value'):
|
if self.prepare_rhs and hasattr(self.lhs.output_field, 'get_prep_value'):
|
||||||
return self.lhs.output_field.get_prep_value(self.rhs)
|
return self.lhs.output_field.get_prep_value(self.rhs)
|
||||||
return self.rhs
|
return self.rhs
|
||||||
|
@ -195,11 +195,9 @@ class FieldGetDbPrepValueIterableMixin(FieldGetDbPrepValueMixin):
|
||||||
get_db_prep_lookup_value_is_iterable = True
|
get_db_prep_lookup_value_is_iterable = True
|
||||||
|
|
||||||
def get_prep_lookup(self):
|
def get_prep_lookup(self):
|
||||||
|
if hasattr(self.rhs, 'resolve_expression'):
|
||||||
|
return self.rhs
|
||||||
prepared_values = []
|
prepared_values = []
|
||||||
if hasattr(self.rhs, '_prepare'):
|
|
||||||
# A subquery is like an iterable but its items shouldn't be
|
|
||||||
# prepared independently.
|
|
||||||
return self.rhs._prepare(self.lhs.output_field)
|
|
||||||
for rhs_value in self.rhs:
|
for rhs_value in self.rhs:
|
||||||
if hasattr(rhs_value, 'resolve_expression'):
|
if hasattr(rhs_value, 'resolve_expression'):
|
||||||
# An expression will be handled by the database but can coexist
|
# An expression will be handled by the database but can coexist
|
||||||
|
|
|
@ -271,9 +271,6 @@ class Query(BaseExpression):
|
||||||
memo[id(self)] = result
|
memo[id(self)] = result
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def _prepare(self, field):
|
|
||||||
return self
|
|
||||||
|
|
||||||
def get_compiler(self, using=None, connection=None):
|
def get_compiler(self, using=None, connection=None):
|
||||||
if using is None and connection is None:
|
if using is None and connection is None:
|
||||||
raise ValueError("Need either using or connection")
|
raise ValueError("Need either using or connection")
|
||||||
|
|
Loading…
Reference in New Issue