kopia lustrzana https://github.com/wagtail/wagtail
Remove partial_match argument from search
rodzic
e97af885ec
commit
e1c8ab4ec0
|
@ -9,7 +9,6 @@ from django.db.models.sql.where import SubqueryConstraint, WhereNode
|
|||
|
||||
from wagtail.search.index import class_is_indexed, get_indexed_models
|
||||
from wagtail.search.query import MATCH_ALL, PlainText
|
||||
from wagtail.utils.deprecation import RemovedInWagtail60Warning
|
||||
|
||||
|
||||
class FilterError(Exception):
|
||||
|
@ -44,7 +43,6 @@ class BaseSearchQueryCompiler:
|
|||
fields=None,
|
||||
operator=None,
|
||||
order_by_relevance=True,
|
||||
partial_match=None, # RemovedInWagtail60Warning
|
||||
):
|
||||
self.queryset = queryset
|
||||
if query is None:
|
||||
|
@ -58,18 +56,6 @@ class BaseSearchQueryCompiler:
|
|||
self.query = query
|
||||
self.fields = fields
|
||||
self.order_by_relevance = order_by_relevance
|
||||
if partial_match:
|
||||
warn(
|
||||
"The partial_match=True argument on `search` is no longer supported. "
|
||||
"Use the `autocomplete` method instead",
|
||||
category=RemovedInWagtail60Warning,
|
||||
)
|
||||
elif partial_match is not None:
|
||||
warn(
|
||||
"The partial_match=False argument on `search` is no longer required "
|
||||
"and should be removed",
|
||||
category=RemovedInWagtail60Warning,
|
||||
)
|
||||
|
||||
def _get_filterable_field(self, field_attname):
|
||||
# Get field
|
||||
|
@ -486,7 +472,6 @@ class BaseSearchBackend:
|
|||
fields=None,
|
||||
operator=None,
|
||||
order_by_relevance=True,
|
||||
partial_match=None, # RemovedInWagtail60Warning
|
||||
):
|
||||
return self._search(
|
||||
self.query_compiler_class,
|
||||
|
@ -495,7 +480,6 @@ class BaseSearchBackend:
|
|||
fields=fields,
|
||||
operator=operator,
|
||||
order_by_relevance=order_by_relevance,
|
||||
partial_match=partial_match, # RemovedInWagtail60Warning
|
||||
)
|
||||
|
||||
def autocomplete(
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import inspect
|
||||
import logging
|
||||
from warnings import warn
|
||||
|
||||
from django.apps import apps
|
||||
from django.core import checks
|
||||
|
@ -10,7 +9,6 @@ from django.db.models.fields.related import ForeignObjectRel, OneToOneRel, Relat
|
|||
from modelcluster.fields import ParentalManyToManyField
|
||||
|
||||
from wagtail.search.backends import get_search_backends_with_name
|
||||
from wagtail.utils.deprecation import RemovedInWagtail60Warning
|
||||
|
||||
logger = logging.getLogger("wagtail.search.index")
|
||||
|
||||
|
@ -295,14 +293,8 @@ class BaseField:
|
|||
|
||||
|
||||
class SearchField(BaseField):
|
||||
def __init__(self, field_name, boost=None, partial_match=False, **kwargs):
|
||||
def __init__(self, field_name, boost=None, **kwargs):
|
||||
super().__init__(field_name, **kwargs)
|
||||
if partial_match:
|
||||
warn(
|
||||
"The partial_match option on SearchField has no effect and will be removed. "
|
||||
"Use AutocompleteField instead",
|
||||
category=RemovedInWagtail60Warning,
|
||||
)
|
||||
self.boost = boost
|
||||
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@ class SearchableQuerySetMixin:
|
|||
fields=None,
|
||||
operator=None,
|
||||
order_by_relevance=True,
|
||||
partial_match=None, # RemovedInWagtail60Warning
|
||||
backend="default",
|
||||
):
|
||||
"""
|
||||
|
@ -21,7 +20,6 @@ class SearchableQuerySetMixin:
|
|||
fields=fields,
|
||||
operator=operator,
|
||||
order_by_relevance=order_by_relevance,
|
||||
partial_match=partial_match, # RemovedInWagtail60Warning
|
||||
)
|
||||
|
||||
def autocomplete(
|
||||
|
|
|
@ -246,8 +246,7 @@ class BackendTests(WagtailTestUtils):
|
|||
)
|
||||
|
||||
def test_autocomplete_uses_autocompletefield(self):
|
||||
# Autocomplete should only require an AutocompleteField, not a SearchField with
|
||||
# partial_match=True
|
||||
# Autocomplete should only require an AutocompleteField, not a SearchField
|
||||
# TODO: given that partial_match=True has no effect as of Wagtail 5, also test that
|
||||
# AutocompleteField is actually being respected, and it's not just relying on the
|
||||
# presence of a SearchField (with or without partial_match)
|
||||
|
|
Ładowanie…
Reference in New Issue