mirror of
https://github.com/django/django.git
synced 2025-11-07 07:15:35 +00:00
Fixed #26285 -- Deprecated the MySQL-specific __search lookup.
This commit is contained in:
@@ -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
|
||||
-------------
|
||||
|
||||
|
||||
Reference in New Issue
Block a user