Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Refactored get_fulltext_search_sql() to DatabaseOperations.fulltext_s…

…earch_sql(). Refs #5106

git-svn-id: http://code.djangoproject.com/svn/django/trunk@5957 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 5a6426448f9813ef9abe17d59eb99e278f9461ee 1 parent 23a736d
Adrian Holovaty authored August 19, 2007
8  django/db/backends/__init__.py
@@ -91,3 +91,11 @@ def drop_foreignkey_sql(self):
91 91
         Returns the SQL command that drops a foreign key.
92 92
         """
93 93
         return "DROP CONSTRAINT"
  94
+
  95
+    def fulltext_search_sql(self, field_name):
  96
+        """
  97
+        Returns the SQL WHERE clause to use in order to perform a full-text
  98
+        search of the given field_name. Note that the resulting string should
  99
+        contain a '%s' placeholder for the value being searched against.
  100
+        """
  101
+        raise NotImplementedError('Full-text search is not implemented for this database backend')
3  django/db/backends/ado_mssql/base.py
@@ -110,9 +110,6 @@ def get_limit_offset_sql(limit, offset=None):
110 110
 def get_random_function_sql():
111 111
     return "RAND()"
112 112
 
113  
-def get_fulltext_search_sql(field_name):
114  
-    raise NotImplementedError
115  
-
116 113
 def get_pk_default_value():
117 114
     return "DEFAULT"
118 115
 
1  django/db/backends/dummy/base.py
@@ -46,7 +46,6 @@ def close(self):
46 46
 get_last_insert_id = complain
47 47
 get_limit_offset_sql = complain
48 48
 get_random_function_sql = complain
49  
-get_fulltext_search_sql = complain
50 49
 get_pk_default_value = complain
51 50
 get_max_name_length = ignore
52 51
 get_start_transaction_sql = complain
6  django/db/backends/mysql/base.py
@@ -74,6 +74,9 @@ def date_trunc_sql(self, lookup_type, field_name):
74 74
     def drop_foreignkey_sql(self):
75 75
         return "DROP FOREIGN KEY"
76 76
 
  77
+    def fulltext_search_sql(self, field_name):
  78
+        return 'MATCH (%s) AGAINST (%%s IN BOOLEAN MODE)' % field_name
  79
+
77 80
 class DatabaseWrapper(BaseDatabaseWrapper):
78 81
     ops = DatabaseOperations()
79 82
 
@@ -164,9 +167,6 @@ def get_limit_offset_sql(limit, offset=None):
164 167
 def get_random_function_sql():
165 168
     return "RAND()"
166 169
 
167  
-def get_fulltext_search_sql(field_name):
168  
-    return 'MATCH (%s) AGAINST (%%s IN BOOLEAN MODE)' % field_name
169  
-
170 170
 def get_pk_default_value():
171 171
     return "DEFAULT"
172 172
 
6  django/db/backends/mysql_old/base.py
@@ -84,6 +84,9 @@ def date_trunc_sql(self, lookup_type, field_name):
84 84
     def drop_foreignkey_sql(self):
85 85
         return "DROP FOREIGN KEY"
86 86
 
  87
+    def fulltext_search_sql(self, field_name):
  88
+        return 'MATCH (%s) AGAINST (%%s IN BOOLEAN MODE)' % field_name
  89
+
87 90
 class DatabaseWrapper(BaseDatabaseWrapper):
88 91
     ops = DatabaseOperations()
89 92
 
@@ -183,9 +186,6 @@ def get_limit_offset_sql(limit, offset=None):
183 186
 def get_random_function_sql():
184 187
     return "RAND()"
185 188
 
186  
-def get_fulltext_search_sql(field_name):
187  
-    return 'MATCH (%s) AGAINST (%%s IN BOOLEAN MODE)' % field_name
188  
-
189 189
 def get_pk_default_value():
190 190
     return "DEFAULT"
191 191
 
3  django/db/backends/oracle/base.py
@@ -186,9 +186,6 @@ def get_limit_offset_sql(limit, offset=None):
186 186
 def get_random_function_sql():
187 187
     return "DBMS_RANDOM.RANDOM"
188 188
 
189  
-def get_fulltext_search_sql(field_name):
190  
-    raise NotImplementedError
191  
-
192 189
 def get_pk_default_value():
193 190
     return "DEFAULT"
194 191
 
3  django/db/backends/postgresql/base.py
@@ -140,9 +140,6 @@ def get_limit_offset_sql(limit, offset=None):
140 140
 def get_random_function_sql():
141 141
     return "RANDOM()"
142 142
 
143  
-def get_fulltext_search_sql(field_name):
144  
-    raise NotImplementedError
145  
-
146 143
 def get_pk_default_value():
147 144
     return "DEFAULT"
148 145
 
3  django/db/backends/postgresql_psycopg2/base.py
@@ -94,9 +94,6 @@ def get_limit_offset_sql(limit, offset=None):
94 94
 def get_random_function_sql():
95 95
     return "RANDOM()"
96 96
 
97  
-def get_fulltext_search_sql(field_name):
98  
-    raise NotImplementedError
99  
-
100 97
 def get_pk_default_value():
101 98
     return "DEFAULT"
102 99
 
3  django/db/backends/sqlite3/base.py
@@ -127,9 +127,6 @@ def get_limit_offset_sql(limit, offset=None):
127 127
 def get_random_function_sql():
128 128
     return "RANDOM()"
129 129
 
130  
-def get_fulltext_search_sql(field_name):
131  
-    raise NotImplementedError
132  
-
133 130
 def get_pk_default_value():
134 131
     return "NULL"
135 132
 
2  django/db/models/query.py
@@ -810,7 +810,7 @@ def get_where_clause(lookup_type, table_prefix, field_name, value, db_type):
810 810
     elif lookup_type == 'isnull':
811 811
         return "%s IS %sNULL" % (field_sql, (not value and 'NOT ' or ''))
812 812
     elif lookup_type == 'search':
813  
-        return backend.get_fulltext_search_sql(field_sql)
  813
+        return connection.ops.fulltext_search_sql(field_sql)
814 814
     elif lookup_type in ('regex', 'iregex'):
815 815
         if settings.DATABASE_ENGINE == 'oracle':
816 816
             if lookup_type == 'regex':

0 notes on commit 5a64264

Please sign in to comment.
Something went wrong with that request. Please try again.