mirror of
				https://github.com/django/django.git
				synced 2025-10-31 01:25:32 +00:00 
			
		
		
		
	Fixed #32693 -- Quoted and lowercased generated column aliases.
This commit is contained in:
		
				
					committed by
					
						 Mariusz Felisiak
						Mariusz Felisiak
					
				
			
			
				
	
			
			
			
						parent
						
							071cf68630
						
					
				
				
					commit
					8de4ca74ba
				
			| @@ -7,7 +7,7 @@ from threading import Lock | ||||
|  | ||||
| from django.core.exceptions import EmptyResultSet, FieldError | ||||
| from django.db import DEFAULT_DB_ALIAS, connection | ||||
| from django.db.models import Count, Exists, F, OuterRef, Q | ||||
| from django.db.models import Count, Exists, F, Max, OuterRef, Q | ||||
| from django.db.models.expressions import RawSQL | ||||
| from django.db.models.sql.constants import LOUTER | ||||
| from django.db.models.sql.where import NothingNode, WhereNode | ||||
| @@ -1855,6 +1855,17 @@ class Queries6Tests(TestCase): | ||||
|             [self.t5, self.t4], | ||||
|         ) | ||||
|  | ||||
|     def test_col_alias_quoted(self): | ||||
|         with CaptureQueriesContext(connection) as captured_queries: | ||||
|             self.assertEqual( | ||||
|                 Tag.objects.values('parent').annotate( | ||||
|                     tag_per_parent=Count('pk'), | ||||
|                 ).aggregate(Max('tag_per_parent')), | ||||
|                 {'tag_per_parent__max': 2}, | ||||
|             ) | ||||
|         sql = captured_queries[0]['sql'] | ||||
|         self.assertIn('AS %s' % connection.ops.quote_name('col1'), sql) | ||||
|  | ||||
|  | ||||
| class RawQueriesTests(TestCase): | ||||
|     @classmethod | ||||
|   | ||||
		Reference in New Issue
	
	Block a user