From ff00a053478fee06bdfb4206c6d4e079e98640ff Mon Sep 17 00:00:00 2001 From: James Turk Date: Fri, 13 Dec 2019 15:10:33 -0500 Subject: Fixed #31088 -- Added support for websearch searching in SearchQuery. --- django/contrib/postgres/search.py | 1 + django/db/backends/postgresql/features.py | 5 +++++ 2 files changed, 6 insertions(+) (limited to 'django') diff --git a/django/contrib/postgres/search.py b/django/contrib/postgres/search.py index 08d92e3514..c3b940d436 100644 --- a/django/contrib/postgres/search.py +++ b/django/contrib/postgres/search.py @@ -134,6 +134,7 @@ class SearchQuery(SearchQueryCombinable, Value): 'plain': 'plainto_tsquery', 'phrase': 'phraseto_tsquery', 'raw': 'to_tsquery', + 'websearch': 'websearch_to_tsquery', } def __init__(self, value, output_field=None, *, config=None, invert=False, search_type='plain'): diff --git a/django/db/backends/postgresql/features.py b/django/db/backends/postgresql/features.py index 58b16d2b48..fad87081b0 100644 --- a/django/db/backends/postgresql/features.py +++ b/django/db/backends/postgresql/features.py @@ -64,6 +64,10 @@ class DatabaseFeatures(BaseDatabaseFeatures): def is_postgresql_10(self): return self.connection.pg_version >= 100000 + @cached_property + def is_postgresql_11(self): + return self.connection.pg_version >= 110000 + @cached_property def is_postgresql_12(self): return self.connection.pg_version >= 120000 @@ -71,4 +75,5 @@ class DatabaseFeatures(BaseDatabaseFeatures): has_bloom_index = property(operator.attrgetter('is_postgresql_9_6')) has_brin_autosummarize = property(operator.attrgetter('is_postgresql_10')) has_phraseto_tsquery = property(operator.attrgetter('is_postgresql_9_6')) + has_websearch_to_tsquery = property(operator.attrgetter('is_postgresql_11')) supports_table_partitions = property(operator.attrgetter('is_postgresql_10')) -- cgit v1.3