0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-11-29 17:36:49 +01:00

Remove deprecated parameters on BaseSearchBackend.search

This commit is contained in:
Matt Westcott 2018-05-18 10:47:10 +01:00 committed by Matt Westcott
parent 31a1126123
commit d1b293da75

View File

@ -1,5 +1,3 @@
import warnings
from warnings import warn
from django.db.models.lookups import Lookup
@ -8,7 +6,6 @@ from django.db.models.sql.where import SubqueryConstraint, WhereNode
from wagtail.search.index import class_is_indexed
from wagtail.search.query import MATCH_ALL, PlainText
from wagtail.utils.deprecation import RemovedInWagtail22Warning
class FilterError(Exception):
@ -301,8 +298,7 @@ class BaseSearchBackend:
def delete(self, obj):
raise NotImplementedError
def search(self, query, model_or_queryset, fields=None, filters=None,
prefetch_related=None, operator=None, order_by_relevance=True):
def search(self, query, model_or_queryset, fields=None, operator=None, order_by_relevance=True):
# Find model/queryset
if isinstance(model_or_queryset, QuerySet):
model = model_or_queryset.model
@ -319,27 +315,6 @@ class BaseSearchBackend:
if query == "":
return EmptySearchResults()
# Apply filters to queryset
if filters:
queryset = queryset.filter(**filters)
warnings.warn(
"The 'filters' argument on the 'search()' method is deprecated. "
"Please apply the filters to the base queryset instead.",
category=RemovedInWagtail22Warning
)
# Prefetch related
if prefetch_related:
for prefetch in prefetch_related:
queryset = queryset.prefetch_related(prefetch)
warnings.warn(
"The 'prefetch_related' argument on the 'search()' method is deprecated. "
"Please add prefetch_related to the base queryset instead.",
category=RemovedInWagtail22Warning
)
# Search
search_query = self.query_compiler_class(
queryset, query, fields=fields, operator=operator, order_by_relevance=order_by_relevance