summaryrefslogtreecommitdiff
path: root/django/contrib/postgres/search.py
diff options
context:
space:
mode:
authorBaptiste Mispelon <bmispelon@gmail.com>2020-03-04 13:33:12 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2020-03-16 10:27:23 +0100
commit3baf92cf8230ad3a932986170fd07c8feae7ff2f (patch)
treed40a4ccf7e8d693615e908fb40f0612e1495635a /django/contrib/postgres/search.py
parent924c01ba095f7df9529a65c176a892a5c1624ec5 (diff)
downloaddjango-3baf92cf8230ad3a932986170fd07c8feae7ff2f.tar.gz
Fixed #31340 -- Allowed query expressions in SearchQuery.value and __search lookup.
Diffstat (limited to 'django/contrib/postgres/search.py')
-rw-r--r--django/contrib/postgres/search.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/django/contrib/postgres/search.py b/django/contrib/postgres/search.py
index 90b6823575..2b2ae0c321 100644
--- a/django/contrib/postgres/search.py
+++ b/django/contrib/postgres/search.py
@@ -11,7 +11,7 @@ class SearchVectorExact(Lookup):
lookup_name = 'exact'
def process_rhs(self, qn, connection):
- if not hasattr(self.rhs, 'resolve_expression'):
+ if not isinstance(self.rhs, (SearchQuery, CombinedSearchQuery)):
config = getattr(self.lhs, 'config', None)
self.rhs = SearchQuery(self.rhs, config=config)
rhs, rhs_params = super().process_rhs(qn, connection)
@@ -170,7 +170,8 @@ class SearchQuery(SearchQueryCombinable, Func):
self.function = self.SEARCH_TYPES.get(search_type)
if self.function is None:
raise ValueError("Unknown search_type argument '%s'." % search_type)
- value = Value(value)
+ if not hasattr(value, 'resolve_expression'):
+ value = Value(value)
expressions = (value,)
self.config = SearchConfig.from_parameter(config)
if self.config is not None: