From 1ba0b22a7a262e63cb7152ef3ab513660156d135 Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Thu, 14 Apr 2016 21:31:23 -0400 Subject: [PATCH] Refs #22936 -- Removed unused code in Field.get_db_prep_lookup(). --- django/db/models/fields/__init__.py | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py index 72d5990dc51..447556cb8c1 100644 --- a/django/db/models/fields/__init__.py +++ b/django/db/models/fields/__init__.py @@ -20,7 +20,7 @@ from django.core import checks, exceptions, validators # purposes. from django.core.exceptions import FieldDoesNotExist # NOQA 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.datastructures import DictWrapper from django.utils.dateparse import ( @@ -780,31 +780,13 @@ class Field(RegisterLookupMixin): if not prepared: value = self.get_prep_lookup(lookup_type, value) 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', - 'icontains', 'iexact', 'startswith', 'endswith', - 'istartswith', 'iendswith'): - return [value] - elif lookup_type in ('exact', 'gt', 'gte', 'lt', 'lte'): + if lookup_type in ('exact', 'gt', 'gte', 'lt', 'lte'): return [self.get_db_prep_value(value, connection=connection, prepared=prepared)] elif lookup_type in ('range', 'in'): return [self.get_db_prep_value(v, connection=connection, prepared=prepared) for v in value] - elif lookup_type == 'isnull': - return [] else: return [value]