Refs #22936 -- Removed unused code in Field.get_db_prep_lookup().

This commit is contained in:
Tim Graham 2016-04-14 21:31:23 -04:00
parent b454e2cbc9
commit 1ba0b22a7a
1 changed files with 2 additions and 20 deletions

View File

@ -20,7 +20,7 @@ from django.core import checks, exceptions, validators
# purposes. # purposes.
from django.core.exceptions import FieldDoesNotExist # NOQA from django.core.exceptions import FieldDoesNotExist # NOQA
from django.db import connection, connections, router from django.db import connection, connections, router
from django.db.models.query_utils import QueryWrapper, RegisterLookupMixin from django.db.models.query_utils import RegisterLookupMixin
from django.utils import six, timezone from django.utils import six, timezone
from django.utils.datastructures import DictWrapper from django.utils.datastructures import DictWrapper
from django.utils.dateparse import ( from django.utils.dateparse import (
@ -780,31 +780,13 @@ class Field(RegisterLookupMixin):
if not prepared: if not prepared:
value = self.get_prep_lookup(lookup_type, value) value = self.get_prep_lookup(lookup_type, value)
prepared = True prepared = True
if hasattr(value, 'get_compiler'):
value = value.get_compiler(connection=connection)
if hasattr(value, 'as_sql') or hasattr(value, '_as_sql'):
# If the value has a relabeled_clone method it means the
# value will be handled later on.
if hasattr(value, 'relabeled_clone'):
return value
if hasattr(value, 'as_sql'):
sql, params = value.as_sql()
else:
sql, params = value._as_sql(connection=connection)
return QueryWrapper(('(%s)' % sql), params)
if lookup_type in ('search', 'regex', 'iregex', 'contains', if lookup_type in ('exact', 'gt', 'gte', 'lt', 'lte'):
'icontains', 'iexact', 'startswith', 'endswith',
'istartswith', 'iendswith'):
return [value]
elif lookup_type in ('exact', 'gt', 'gte', 'lt', 'lte'):
return [self.get_db_prep_value(value, connection=connection, return [self.get_db_prep_value(value, connection=connection,
prepared=prepared)] prepared=prepared)]
elif lookup_type in ('range', 'in'): elif lookup_type in ('range', 'in'):
return [self.get_db_prep_value(v, connection=connection, return [self.get_db_prep_value(v, connection=connection,
prepared=prepared) for v in value] prepared=prepared) for v in value]
elif lookup_type == 'isnull':
return []
else: else:
return [value] return [value]