1
0
mirror of https://github.com/django/django.git synced 2025-10-25 22:56:12 +00:00

Fixed #26285 -- Deprecated the MySQL-specific __search lookup.

This commit is contained in:
Marc Tamlyn
2015-06-05 12:31:44 +01:00
committed by Tim Graham
parent 04240b2365
commit 8ddc79a799
9 changed files with 46 additions and 10 deletions

View File

@@ -191,6 +191,7 @@ class BaseDatabaseOperations(object):
search of the given field_name. Note that the resulting string should
contain a '%s' placeholder for the value being searched against.
"""
# RemovedInDjango20Warning
raise NotImplementedError('Full-text search is not implemented for this database backend')
def last_executed_query(self, cursor, sql, params):

View File

@@ -91,6 +91,7 @@ class DatabaseOperations(BaseDatabaseOperations):
return [(None, ("NULL", [], False))]
def fulltext_search_sql(self, field_name):
# RemovedInDjango20Warning
return 'MATCH (%s) AGAINST (%%s IN BOOLEAN MODE)' % field_name
def last_executed_query(self, cursor, sql, params):

View File

@@ -1,3 +1,4 @@
import warnings
from copy import copy
from django.conf import settings
@@ -7,6 +8,7 @@ from django.db.models.fields import (
)
from django.db.models.query_utils import RegisterLookupMixin
from django.utils import timezone
from django.utils.deprecation import RemovedInDjango20Warning
from django.utils.functional import cached_property
from django.utils.six.moves import range
@@ -373,6 +375,10 @@ class Search(BuiltinLookup):
lookup_name = 'search'
def as_sql(self, compiler, connection):
warnings.warn(
'The `__search` lookup is deprecated. See the 1.10 release notes '
'for how to replace it.', RemovedInDjango20Warning, stacklevel=2
)
lhs, lhs_params = self.process_lhs(compiler, connection)
rhs, rhs_params = self.process_rhs(compiler, connection)
sql_template = connection.ops.fulltext_search_sql(field_name=lhs)