diff options
| author | Tom Forbes <tom@tomforb.es> | 2018-08-07 22:32:29 +0100 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2018-08-15 16:47:23 -0400 |
| commit | a3df7574f934673d9c77154bb3e69917ebf85e3e (patch) | |
| tree | 6406637ec10f33e5516af4083c744e8383891dae /django | |
| parent | 7cc52250f06c2a4769badbab1d7ee01f8e3cb46a (diff) | |
Fixed #29644 -- Made SearchQuery.__str__() reflect negation and grouping.
Diffstat (limited to 'django')
| -rw-r--r-- | django/contrib/postgres/search.py | 7 |
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' |
