Removed obsolete Lookup hook to prepare rhs expressions.

After 3a505c70e7, all _prepare() methods
return self.
This commit is contained in:
Simon Charette 2019-03-06 02:05:32 -05:00 committed by Tim Graham
parent 3a505c70e7
commit 5935a9aead
4 changed files with 5 additions and 21 deletions

View File

@ -240,8 +240,7 @@ class ArrayLenTransform(Transform):
class ArrayInLookup(In):
def get_prep_lookup(self):
values = super().get_prep_lookup()
if hasattr(self.rhs, '_prepare'):
# Subqueries don't need further preparation.
if hasattr(values, 'resolve_expression'):
return values
# In.process_rhs() expects values to be hashable, so convert lists
# to tuples.

View File

@ -245,10 +245,6 @@ class BaseExpression:
])
return c
def _prepare(self, field):
"""Hook used by Lookup.get_prep_lookup() to do custom preparation."""
return self
@property
def field(self):
return self.output_field
@ -537,9 +533,6 @@ class ResolvedOuterRef(F):
'only be used in a subquery.'
)
def _prepare(self, output_field=None):
return self
def relabeled_clone(self, relabels):
return self
@ -551,9 +544,6 @@ class OuterRef(F):
return self.name
return ResolvedOuterRef(self.name)
def _prepare(self, output_field=None):
return self
class Func(SQLiteNumericMixin, Expression):
"""An SQL function call."""

View File

@ -64,8 +64,8 @@ class Lookup:
self.lhs, self.rhs = new_exprs
def get_prep_lookup(self):
if hasattr(self.rhs, '_prepare'):
return self.rhs._prepare(self.lhs.output_field)
if hasattr(self.rhs, 'resolve_expression'):
return self.rhs
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.rhs
@ -195,11 +195,9 @@ class FieldGetDbPrepValueIterableMixin(FieldGetDbPrepValueMixin):
get_db_prep_lookup_value_is_iterable = True
def get_prep_lookup(self):
if hasattr(self.rhs, 'resolve_expression'):
return self.rhs
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:
if hasattr(rhs_value, 'resolve_expression'):
# An expression will be handled by the database but can coexist

View File

@ -271,9 +271,6 @@ class Query(BaseExpression):
memo[id(self)] = result
return result
def _prepare(self, field):
return self
def get_compiler(self, using=None, connection=None):
if using is None and connection is None:
raise ValueError("Need either using or connection")