diff options
| author | adamb70 <adam.boaler@hotmail.com> | 2020-02-05 01:51:13 +0000 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2020-02-06 07:52:50 +0100 |
| commit | 4c6ab1f2aa2a99d17ab308c0156f971a13d3fcaf (patch) | |
| tree | 25aedf4a2affb4101812067e3bb572f96ab0ebf6 | |
| parent | 72b97a5b1e22f5d464045be2e33f0436fa8061d3 (diff) | |
Fixed #28528 -- Allowed combining SearchVectors with different configs.
| -rw-r--r-- | django/contrib/postgres/search.py | 2 | ||||
| -rw-r--r-- | tests/postgres_tests/test_search.py | 11 |
2 files changed, 12 insertions, 1 deletions
diff --git a/django/contrib/postgres/search.py b/django/contrib/postgres/search.py index 000241ba24..2786251548 100644 --- a/django/contrib/postgres/search.py +++ b/django/contrib/postgres/search.py @@ -56,7 +56,7 @@ class SearchVectorCombinable: ADD = '||' def _combine(self, other, connector, reversed): - if not isinstance(other, SearchVectorCombinable) or not self.config == other.config: + if not isinstance(other, SearchVectorCombinable): raise TypeError( 'SearchVector can only be combined with other SearchVector ' 'instances, got %s.' % type(other).__name__ diff --git a/tests/postgres_tests/test_search.py b/tests/postgres_tests/test_search.py index 068a4afe93..89aa8c6662 100644 --- a/tests/postgres_tests/test_search.py +++ b/tests/postgres_tests/test_search.py @@ -297,6 +297,17 @@ class TestCombinations(GrailTestData, PostgreSQLTestCase): with self.assertRaisesMessage(TypeError, msg): Line.objects.filter(dialogue__search=None + SearchVector('character__name')) + def test_combine_different_vector_configs(self): + searched = Line.objects.annotate( + search=( + SearchVector('dialogue', config='english') + + SearchVector('dialogue', config='french') + ), + ).filter( + search=SearchQuery('cadeaux', config='french') | SearchQuery('nostrils') + ) + self.assertCountEqual(searched, [self.french, self.verse2]) + def test_query_and(self): searched = Line.objects.annotate( search=SearchVector('scene__setting', 'dialogue'), |
