mirror of
https://github.com/django/django.git
synced 2024-12-23 01:25:58 +00:00
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:
parent
df4d622cac
commit
7c8b043a03
@ -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
|
||||
|
||||
|
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user