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:
parent
23a736dca9
commit
5a6426448f
|
@ -91,3 +91,11 @@ class BaseDatabaseOperations(object):
|
|||
Returns the SQL command that drops a foreign key.
|
||||
"""
|
||||
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():
|
||||
return "RAND()"
|
||||
|
||||
def get_fulltext_search_sql(field_name):
|
||||
raise NotImplementedError
|
||||
|
||||
def get_pk_default_value():
|
||||
return "DEFAULT"
|
||||
|
||||
|
|
|
@ -46,7 +46,6 @@ dictfetchall = complain
|
|||
get_last_insert_id = complain
|
||||
get_limit_offset_sql = complain
|
||||
get_random_function_sql = complain
|
||||
get_fulltext_search_sql = complain
|
||||
get_pk_default_value = complain
|
||||
get_max_name_length = ignore
|
||||
get_start_transaction_sql = complain
|
||||
|
|
|
@ -74,6 +74,9 @@ class DatabaseOperations(BaseDatabaseOperations):
|
|||
def drop_foreignkey_sql(self):
|
||||
return "DROP FOREIGN KEY"
|
||||
|
||||
def fulltext_search_sql(self, field_name):
|
||||
return 'MATCH (%s) AGAINST (%%s IN BOOLEAN MODE)' % field_name
|
||||
|
||||
class DatabaseWrapper(BaseDatabaseWrapper):
|
||||
ops = DatabaseOperations()
|
||||
|
||||
|
@ -164,9 +167,6 @@ def get_limit_offset_sql(limit, offset=None):
|
|||
def get_random_function_sql():
|
||||
return "RAND()"
|
||||
|
||||
def get_fulltext_search_sql(field_name):
|
||||
return 'MATCH (%s) AGAINST (%%s IN BOOLEAN MODE)' % field_name
|
||||
|
||||
def get_pk_default_value():
|
||||
return "DEFAULT"
|
||||
|
||||
|
|
|
@ -84,6 +84,9 @@ class DatabaseOperations(BaseDatabaseOperations):
|
|||
def drop_foreignkey_sql(self):
|
||||
return "DROP FOREIGN KEY"
|
||||
|
||||
def fulltext_search_sql(self, field_name):
|
||||
return 'MATCH (%s) AGAINST (%%s IN BOOLEAN MODE)' % field_name
|
||||
|
||||
class DatabaseWrapper(BaseDatabaseWrapper):
|
||||
ops = DatabaseOperations()
|
||||
|
||||
|
@ -183,9 +186,6 @@ def get_limit_offset_sql(limit, offset=None):
|
|||
def get_random_function_sql():
|
||||
return "RAND()"
|
||||
|
||||
def get_fulltext_search_sql(field_name):
|
||||
return 'MATCH (%s) AGAINST (%%s IN BOOLEAN MODE)' % field_name
|
||||
|
||||
def get_pk_default_value():
|
||||
return "DEFAULT"
|
||||
|
||||
|
|
|
@ -186,9 +186,6 @@ def get_limit_offset_sql(limit, offset=None):
|
|||
def get_random_function_sql():
|
||||
return "DBMS_RANDOM.RANDOM"
|
||||
|
||||
def get_fulltext_search_sql(field_name):
|
||||
raise NotImplementedError
|
||||
|
||||
def get_pk_default_value():
|
||||
return "DEFAULT"
|
||||
|
||||
|
|
|
@ -140,9 +140,6 @@ def get_limit_offset_sql(limit, offset=None):
|
|||
def get_random_function_sql():
|
||||
return "RANDOM()"
|
||||
|
||||
def get_fulltext_search_sql(field_name):
|
||||
raise NotImplementedError
|
||||
|
||||
def get_pk_default_value():
|
||||
return "DEFAULT"
|
||||
|
||||
|
|
|
@ -94,9 +94,6 @@ def get_limit_offset_sql(limit, offset=None):
|
|||
def get_random_function_sql():
|
||||
return "RANDOM()"
|
||||
|
||||
def get_fulltext_search_sql(field_name):
|
||||
raise NotImplementedError
|
||||
|
||||
def get_pk_default_value():
|
||||
return "DEFAULT"
|
||||
|
||||
|
|
|
@ -127,9 +127,6 @@ def get_limit_offset_sql(limit, offset=None):
|
|||
def get_random_function_sql():
|
||||
return "RANDOM()"
|
||||
|
||||
def get_fulltext_search_sql(field_name):
|
||||
raise NotImplementedError
|
||||
|
||||
def get_pk_default_value():
|
||||
return "NULL"
|
||||
|
||||
|
|
|
@ -810,7 +810,7 @@ def get_where_clause(lookup_type, table_prefix, field_name, value, db_type):
|
|||
elif lookup_type == 'isnull':
|
||||
return "%s IS %sNULL" % (field_sql, (not value and 'NOT ' or ''))
|
||||
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'):
|
||||
if settings.DATABASE_ENGINE == 'oracle':
|
||||
if lookup_type == 'regex':
|
||||
|
|
Loading…
Reference in New Issue