mirror of
https://github.com/django/django.git
synced 2025-08-03 18:38:50 +00:00
Fixed #26285 -- Deprecated the MySQL-specific __search lookup.
This commit is contained in:
parent
04240b2365
commit
8ddc79a799
9 changed files with 46 additions and 10 deletions
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
|
|
@ -2771,6 +2771,11 @@ SQL equivalent::
|
|||
``search``
|
||||
~~~~~~~~~~
|
||||
|
||||
.. deprecated:: 1.10
|
||||
|
||||
See :ref:`the 1.10 release notes <search-lookup-replacement>` for how to
|
||||
replace it.
|
||||
|
||||
A boolean full-text search, taking advantage of full-text indexing. This is
|
||||
like :lookup:`contains` but is significantly faster due to full-text indexing.
|
||||
|
||||
|
|
|
@ -740,6 +740,28 @@ use the default_related_name ``bars``::
|
|||
|
||||
>>> Foo.object.get(bars=bar)
|
||||
|
||||
.. _search-lookup-replacement:
|
||||
|
||||
``__search`` query lookup
|
||||
-------------------------
|
||||
|
||||
The ``search`` lookup, which supports MySQL only and is extremely limited in
|
||||
features, is deprecated. Replace it with a custom lookup::
|
||||
|
||||
from django.db import models
|
||||
|
||||
class Search(models.Lookup):
|
||||
lookup_name = 'search'
|
||||
|
||||
def as_mysql(self, compiler, connection):
|
||||
lhs, lhs_params = self.process_lhs(compiler, connection)
|
||||
rhs, rhs_params = self.process_rhs(compiler, connection)
|
||||
params = lhs_params + rhs_params
|
||||
return 'MATCH (%s) AGAINST (%s IN BOOLEAN MODE)' % (lhs, rhs), params
|
||||
|
||||
models.CharField.register_lookup(Search)
|
||||
models.TextField.register_lookup(Search)
|
||||
|
||||
Miscellaneous
|
||||
-------------
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue