Refs #31304 -- Made __search lookup default to its rhs' config.

This make the SearchLookup lookup more coherent with its
SearchVectorExact base which configures its rhs SearchQuery with its
lhs' config.
This commit is contained in:
Simon Charette 2020-02-24 23:51:27 -05:00 committed by Mariusz Felisiak
parent df4d622cac
commit 7c8b043a03
2 changed files with 8 additions and 1 deletions

View File

@ -57,7 +57,8 @@ class SearchLookup(SearchVectorExact):
def process_lhs(self, qn, connection):
if not isinstance(self.lhs.output_field, SearchVectorField):
self.lhs = SearchVector(self.lhs)
config = getattr(self.rhs, 'config', None)
self.lhs = SearchVector(self.lhs, config=config)
lhs, lhs_params = super().process_lhs(qn, connection)
return lhs, lhs_params

View File

@ -104,6 +104,12 @@ class SimpleSearchTest(GrailTestData, PostgreSQLTestCase):
searched = Line.objects.filter(dialogue__search='Robin killed')
self.assertSequenceEqual(searched, [self.verse0])
def test_search_query_config(self):
searched = Line.objects.filter(
dialogue__search=SearchQuery('nostrils', config='simple'),
)
self.assertSequenceEqual(searched, [self.verse2])
@modify_settings(INSTALLED_APPS={'append': 'django.contrib.postgres'})
class SearchVectorFieldTest(GrailTestData, PostgreSQLTestCase):