Refactored get_field_cast_sql() to DatabaseOperations.field_cast_sql(). Refs #5106
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5977 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
e13ea3c70d
commit
4c5248f98f
|
@ -103,6 +103,15 @@ class BaseDatabaseOperations(object):
|
|||
"""
|
||||
return "DROP CONSTRAINT"
|
||||
|
||||
def field_cast_sql(self, db_type):
|
||||
"""
|
||||
Given a column type (e.g. 'BLOB', 'VARCHAR'), returns the SQL necessary
|
||||
to cast it before using it in a WHERE statement. Note that the
|
||||
resulting string should contain a '%s' placeholder for the column being
|
||||
searched against.
|
||||
"""
|
||||
return '%s'
|
||||
|
||||
def fulltext_search_sql(self, field_name):
|
||||
"""
|
||||
Returns the SQL WHERE clause to use in order to perform a full-text
|
||||
|
|
|
@ -66,6 +66,12 @@ class DatabaseOperations(BaseDatabaseOperations):
|
|||
def deferrable_sql(self):
|
||||
return " DEFERRABLE INITIALLY DEFERRED"
|
||||
|
||||
def field_cast_sql(self, db_type):
|
||||
if db_type.endswith('LOB'):
|
||||
return "DBMS_LOB.SUBSTR(%s)"
|
||||
else:
|
||||
return "%s"
|
||||
|
||||
def last_insert_id(self, cursor, table_name, pk_name):
|
||||
sq_name = util.truncate_name(table_name, self.max_name_length() - 3)
|
||||
cursor.execute('SELECT %s_sq.currval FROM dual' % sq_name)
|
||||
|
@ -462,12 +468,6 @@ def to_unicode(s):
|
|||
return force_unicode(s)
|
||||
return s
|
||||
|
||||
def get_field_cast_sql(db_type):
|
||||
if db_type.endswith('LOB'):
|
||||
return "DBMS_LOB.SUBSTR(%s%s)"
|
||||
else:
|
||||
return "%s%s"
|
||||
|
||||
def get_drop_sequence(table):
|
||||
return "DROP SEQUENCE %s;" % DatabaseOperations().quote_name(get_sequence_name(table))
|
||||
|
||||
|
|
|
@ -791,11 +791,7 @@ def get_where_clause(lookup_type, table_prefix, field_name, value, db_type):
|
|||
cast_sql = connection.ops.datetime_cast_sql()
|
||||
else:
|
||||
cast_sql = '%s'
|
||||
if db_type and hasattr(backend, 'get_field_cast_sql'):
|
||||
field_cast_sql = backend.get_field_cast_sql(db_type)
|
||||
else:
|
||||
field_cast_sql = '%s%s'
|
||||
field_sql = field_cast_sql % (table_prefix, field_name)
|
||||
field_sql = connection.ops.field_cast_sql(db_type) % (table_prefix + field_name)
|
||||
if lookup_type in ('iexact', 'icontains', 'istartswith', 'iendswith') and connection.features.needs_upper_for_iops:
|
||||
format = 'UPPER(%s) %s'
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue