summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
Diffstat (limited to 'django')
-rw-r--r--django/contrib/postgres/search.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/django/contrib/postgres/search.py b/django/contrib/postgres/search.py
index 7bda2291a0..63fa9116ec 100644
--- a/django/contrib/postgres/search.py
+++ b/django/contrib/postgres/search.py
@@ -158,12 +158,19 @@ class SearchQuery(SearchQueryCombinable, Value):
def __invert__(self):
return type(self)(self.value, config=self.config, invert=not self.invert)
+ def __str__(self):
+ result = super().__str__()
+ return ('~%s' % result) if self.invert else result
+
class CombinedSearchQuery(SearchQueryCombinable, CombinedExpression):
def __init__(self, lhs, connector, rhs, config, output_field=None):
self.config = config
super().__init__(lhs, connector, rhs, output_field)
+ def __str__(self):
+ return '(%s)' % super().__str__()
+
class SearchRank(Func):
function = 'ts_rank'