mirror of
				https://github.com/django/django.git
				synced 2025-10-31 09:41:08 +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:
		
				
					committed by
					
						 Mariusz Felisiak
						Mariusz Felisiak
					
				
			
			
				
	
			
			
			
						parent
						
							df4d622cac
						
					
				
				
					commit
					7c8b043a03
				
			| @@ -57,7 +57,8 @@ class SearchLookup(SearchVectorExact): | |||||||
|  |  | ||||||
|     def process_lhs(self, qn, connection): |     def process_lhs(self, qn, connection): | ||||||
|         if not isinstance(self.lhs.output_field, SearchVectorField): |         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) |         lhs, lhs_params = super().process_lhs(qn, connection) | ||||||
|         return lhs, lhs_params |         return lhs, lhs_params | ||||||
|  |  | ||||||
|   | |||||||
| @@ -104,6 +104,12 @@ class SimpleSearchTest(GrailTestData, PostgreSQLTestCase): | |||||||
|         searched = Line.objects.filter(dialogue__search='Robin killed') |         searched = Line.objects.filter(dialogue__search='Robin killed') | ||||||
|         self.assertSequenceEqual(searched, [self.verse0]) |         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'}) | @modify_settings(INSTALLED_APPS={'append': 'django.contrib.postgres'}) | ||||||
| class SearchVectorFieldTest(GrailTestData, PostgreSQLTestCase): | class SearchVectorFieldTest(GrailTestData, PostgreSQLTestCase): | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user