mirror of
				https://github.com/django/django.git
				synced 2025-10-30 17:16:10 +00:00 
			
		
		
		
	Fixed #31228 -- Reallowed aggregates to be used with multiple expressions and no DISTINCT on SQLite.
Regression in bc05547cd8.
Thanks Andy Terra for the report.
			
			
This commit is contained in:
		| @@ -56,7 +56,11 @@ class DatabaseOperations(BaseDatabaseOperations): | ||||
|                             'aggregations on date/time fields in sqlite3 ' | ||||
|                             'since date/time is saved as text.' | ||||
|                         ) | ||||
|         if isinstance(expression, models.Aggregate) and len(expression.source_expressions) > 1: | ||||
|         if ( | ||||
|             isinstance(expression, models.Aggregate) and | ||||
|             expression.distinct and | ||||
|             len(expression.source_expressions) > 1 | ||||
|         ): | ||||
|             raise NotSupportedError( | ||||
|                 "SQLite doesn't support DISTINCT on aggregate functions " | ||||
|                 "accepting multiple arguments." | ||||
|   | ||||
| @@ -63,6 +63,15 @@ class Tests(TestCase): | ||||
|         with self.assertRaisesMessage(NotSupportedError, msg): | ||||
|             connection.ops.check_expression_support(aggregate) | ||||
|  | ||||
|     def test_distinct_aggregation_multiple_args_no_distinct(self): | ||||
|         # Aggregate functions accept multiple arguments when DISTINCT isn't | ||||
|         # used, e.g. GROUP_CONCAT(). | ||||
|         class DistinctAggregate(Aggregate): | ||||
|             allow_distinct = True | ||||
|  | ||||
|         aggregate = DistinctAggregate('first', 'second', distinct=False) | ||||
|         connection.ops.check_expression_support(aggregate) | ||||
|  | ||||
|     def test_memory_db_test_name(self): | ||||
|         """A named in-memory db should be allowed where supported.""" | ||||
|         from django.db.backends.sqlite3.base import DatabaseWrapper | ||||
|   | ||||
		Reference in New Issue
	
	Block a user