mirror of
				https://github.com/django/django.git
				synced 2025-10-31 01:25:32 +00:00 
			
		
		
		
	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:
		| @@ -103,6 +103,15 @@ class BaseDatabaseOperations(object): | |||||||
|         """ |         """ | ||||||
|         return "DROP CONSTRAINT" |         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): |     def fulltext_search_sql(self, field_name): | ||||||
|         """ |         """ | ||||||
|         Returns the SQL WHERE clause to use in order to perform a full-text |         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): |     def deferrable_sql(self): | ||||||
|         return " DEFERRABLE INITIALLY DEFERRED" |         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): |     def last_insert_id(self, cursor, table_name, pk_name): | ||||||
|         sq_name = util.truncate_name(table_name, self.max_name_length() - 3) |         sq_name = util.truncate_name(table_name, self.max_name_length() - 3) | ||||||
|         cursor.execute('SELECT %s_sq.currval FROM dual' % sq_name) |         cursor.execute('SELECT %s_sq.currval FROM dual' % sq_name) | ||||||
| @@ -462,12 +468,6 @@ def to_unicode(s): | |||||||
|         return force_unicode(s) |         return force_unicode(s) | ||||||
|     return 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): | def get_drop_sequence(table): | ||||||
|     return "DROP SEQUENCE %s;" % DatabaseOperations().quote_name(get_sequence_name(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() |         cast_sql = connection.ops.datetime_cast_sql() | ||||||
|     else: |     else: | ||||||
|         cast_sql = '%s' |         cast_sql = '%s' | ||||||
|     if db_type and hasattr(backend, 'get_field_cast_sql'): |     field_sql = connection.ops.field_cast_sql(db_type) % (table_prefix + field_name) | ||||||
|         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) |  | ||||||
|     if lookup_type in ('iexact', 'icontains', 'istartswith', 'iendswith') and connection.features.needs_upper_for_iops: |     if lookup_type in ('iexact', 'icontains', 'istartswith', 'iendswith') and connection.features.needs_upper_for_iops: | ||||||
|         format = 'UPPER(%s) %s' |         format = 'UPPER(%s) %s' | ||||||
|     else: |     else: | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user