Commit 8ddc79a7 authored by Marc Tamlyn's avatar Marc Tamlyn Committed by Tim Graham
Browse files

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

parent 04240b23
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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):
+1 −0
Original line number Diff line number Diff line
@@ -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):
+6 −0
Original line number Diff line number Diff line
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)
+3 −0
Original line number Diff line number Diff line
@@ -141,6 +141,9 @@ details on these changes.
* Support for query lookups using the model name when
  ``Meta.default_related_name`` is set will be removed.

* The ``__search`` query lookup and the
  ``DatabaseOperations.fulltext_search_sql()`` method will be removed.

.. _deprecation-removed-in-1.10:

1.10
+2 −9
Original line number Diff line number Diff line
@@ -1847,15 +1847,8 @@ Field API reference
    .. method:: get_prep_lookup(lookup_type, value)

        Prepares ``value`` to the database prior to be used in a lookup.
        The ``lookup_type`` will be one of the valid Django filter lookups:
        ``"exact"``, ``"iexact"``, ``"contains"``, ``"icontains"``,
        ``"gt"``, ``"gte"``, ``"lt"``, ``"lte"``, ``"in"``, ``"startswith"``,
        ``"istartswith"``, ``"endswith"``, ``"iendswith"``, ``"range"``,
        ``"year"``, ``"month"``, ``"day"``, ``"isnull"``, ``"search"``,
        ``"regex"``, and ``"iregex"``.

        If you are using :doc:`Custom lookups </ref/models/lookups>` the
        ``lookup_type`` can be any ``lookup_name`` registered in the field.
        The ``lookup_type`` will be the registered name of the lookup. For
        example: ``"exact"``, ``"iexact"``, or ``"contains"``.

        See :ref:`preparing-values-for-use-in-database-lookups` for usage.

Loading