mirror of
				https://github.com/django/django.git
				synced 2025-10-26 07:06:08 +00:00 
			
		
		
		
	Refactored get_fulltext_search_sql() to DatabaseOperations.fulltext_search_sql(). Refs #5106
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5957 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
		| @@ -91,3 +91,11 @@ class BaseDatabaseOperations(object): | |||||||
|         Returns the SQL command that drops a foreign key. |         Returns the SQL command that drops a foreign key. | ||||||
|         """ |         """ | ||||||
|         return "DROP CONSTRAINT" |         return "DROP CONSTRAINT" | ||||||
|  |  | ||||||
|  |     def fulltext_search_sql(self, field_name): | ||||||
|  |         """ | ||||||
|  |         Returns the SQL WHERE clause to use in order to perform a full-text | ||||||
|  |         search of the given field_name. Note that the resulting string should | ||||||
|  |         contain a '%s' placeholder for the value being searched against. | ||||||
|  |         """ | ||||||
|  |         raise NotImplementedError('Full-text search is not implemented for this database backend') | ||||||
|   | |||||||
| @@ -110,9 +110,6 @@ def get_limit_offset_sql(limit, offset=None): | |||||||
| def get_random_function_sql(): | def get_random_function_sql(): | ||||||
|     return "RAND()" |     return "RAND()" | ||||||
|  |  | ||||||
| def get_fulltext_search_sql(field_name): |  | ||||||
|     raise NotImplementedError |  | ||||||
|  |  | ||||||
| def get_pk_default_value(): | def get_pk_default_value(): | ||||||
|     return "DEFAULT" |     return "DEFAULT" | ||||||
|  |  | ||||||
|   | |||||||
| @@ -46,7 +46,6 @@ dictfetchall = complain | |||||||
| get_last_insert_id = complain | get_last_insert_id = complain | ||||||
| get_limit_offset_sql = complain | get_limit_offset_sql = complain | ||||||
| get_random_function_sql = complain | get_random_function_sql = complain | ||||||
| get_fulltext_search_sql = complain |  | ||||||
| get_pk_default_value = complain | get_pk_default_value = complain | ||||||
| get_max_name_length = ignore | get_max_name_length = ignore | ||||||
| get_start_transaction_sql = complain | get_start_transaction_sql = complain | ||||||
|   | |||||||
| @@ -74,6 +74,9 @@ class DatabaseOperations(BaseDatabaseOperations): | |||||||
|     def drop_foreignkey_sql(self): |     def drop_foreignkey_sql(self): | ||||||
|         return "DROP FOREIGN KEY" |         return "DROP FOREIGN KEY" | ||||||
|  |  | ||||||
|  |     def fulltext_search_sql(self, field_name): | ||||||
|  |         return 'MATCH (%s) AGAINST (%%s IN BOOLEAN MODE)' % field_name | ||||||
|  |  | ||||||
| class DatabaseWrapper(BaseDatabaseWrapper): | class DatabaseWrapper(BaseDatabaseWrapper): | ||||||
|     ops = DatabaseOperations() |     ops = DatabaseOperations() | ||||||
|  |  | ||||||
| @@ -164,9 +167,6 @@ def get_limit_offset_sql(limit, offset=None): | |||||||
| def get_random_function_sql(): | def get_random_function_sql(): | ||||||
|     return "RAND()" |     return "RAND()" | ||||||
|  |  | ||||||
| def get_fulltext_search_sql(field_name): |  | ||||||
|     return 'MATCH (%s) AGAINST (%%s IN BOOLEAN MODE)' % field_name |  | ||||||
|  |  | ||||||
| def get_pk_default_value(): | def get_pk_default_value(): | ||||||
|     return "DEFAULT" |     return "DEFAULT" | ||||||
|  |  | ||||||
|   | |||||||
| @@ -84,6 +84,9 @@ class DatabaseOperations(BaseDatabaseOperations): | |||||||
|     def drop_foreignkey_sql(self): |     def drop_foreignkey_sql(self): | ||||||
|         return "DROP FOREIGN KEY" |         return "DROP FOREIGN KEY" | ||||||
|  |  | ||||||
|  |     def fulltext_search_sql(self, field_name): | ||||||
|  |         return 'MATCH (%s) AGAINST (%%s IN BOOLEAN MODE)' % field_name | ||||||
|  |  | ||||||
| class DatabaseWrapper(BaseDatabaseWrapper): | class DatabaseWrapper(BaseDatabaseWrapper): | ||||||
|     ops = DatabaseOperations() |     ops = DatabaseOperations() | ||||||
|  |  | ||||||
| @@ -183,9 +186,6 @@ def get_limit_offset_sql(limit, offset=None): | |||||||
| def get_random_function_sql(): | def get_random_function_sql(): | ||||||
|     return "RAND()" |     return "RAND()" | ||||||
|  |  | ||||||
| def get_fulltext_search_sql(field_name): |  | ||||||
|     return 'MATCH (%s) AGAINST (%%s IN BOOLEAN MODE)' % field_name |  | ||||||
|  |  | ||||||
| def get_pk_default_value(): | def get_pk_default_value(): | ||||||
|     return "DEFAULT" |     return "DEFAULT" | ||||||
|  |  | ||||||
|   | |||||||
| @@ -186,9 +186,6 @@ def get_limit_offset_sql(limit, offset=None): | |||||||
| def get_random_function_sql(): | def get_random_function_sql(): | ||||||
|     return "DBMS_RANDOM.RANDOM" |     return "DBMS_RANDOM.RANDOM" | ||||||
|  |  | ||||||
| def get_fulltext_search_sql(field_name): |  | ||||||
|     raise NotImplementedError |  | ||||||
|  |  | ||||||
| def get_pk_default_value(): | def get_pk_default_value(): | ||||||
|     return "DEFAULT" |     return "DEFAULT" | ||||||
|  |  | ||||||
|   | |||||||
| @@ -140,9 +140,6 @@ def get_limit_offset_sql(limit, offset=None): | |||||||
| def get_random_function_sql(): | def get_random_function_sql(): | ||||||
|     return "RANDOM()" |     return "RANDOM()" | ||||||
|  |  | ||||||
| def get_fulltext_search_sql(field_name): |  | ||||||
|     raise NotImplementedError |  | ||||||
|  |  | ||||||
| def get_pk_default_value(): | def get_pk_default_value(): | ||||||
|     return "DEFAULT" |     return "DEFAULT" | ||||||
|  |  | ||||||
|   | |||||||
| @@ -94,9 +94,6 @@ def get_limit_offset_sql(limit, offset=None): | |||||||
| def get_random_function_sql(): | def get_random_function_sql(): | ||||||
|     return "RANDOM()" |     return "RANDOM()" | ||||||
|  |  | ||||||
| def get_fulltext_search_sql(field_name): |  | ||||||
|     raise NotImplementedError |  | ||||||
|  |  | ||||||
| def get_pk_default_value(): | def get_pk_default_value(): | ||||||
|     return "DEFAULT" |     return "DEFAULT" | ||||||
|  |  | ||||||
|   | |||||||
| @@ -127,9 +127,6 @@ def get_limit_offset_sql(limit, offset=None): | |||||||
| def get_random_function_sql(): | def get_random_function_sql(): | ||||||
|     return "RANDOM()" |     return "RANDOM()" | ||||||
|  |  | ||||||
| def get_fulltext_search_sql(field_name): |  | ||||||
|     raise NotImplementedError |  | ||||||
|  |  | ||||||
| def get_pk_default_value(): | def get_pk_default_value(): | ||||||
|     return "NULL" |     return "NULL" | ||||||
|  |  | ||||||
|   | |||||||
| @@ -810,7 +810,7 @@ def get_where_clause(lookup_type, table_prefix, field_name, value, db_type): | |||||||
|     elif lookup_type == 'isnull': |     elif lookup_type == 'isnull': | ||||||
|         return "%s IS %sNULL" % (field_sql, (not value and 'NOT ' or '')) |         return "%s IS %sNULL" % (field_sql, (not value and 'NOT ' or '')) | ||||||
|     elif lookup_type == 'search': |     elif lookup_type == 'search': | ||||||
|         return backend.get_fulltext_search_sql(field_sql) |         return connection.ops.fulltext_search_sql(field_sql) | ||||||
|     elif lookup_type in ('regex', 'iregex'): |     elif lookup_type in ('regex', 'iregex'): | ||||||
|         if settings.DATABASE_ENGINE == 'oracle': |         if settings.DATABASE_ENGINE == 'oracle': | ||||||
|             if lookup_type == 'regex': |             if lookup_type == 'regex': | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user