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:
parent
f37d548ede
commit
cbb6531e5b
|
@ -56,7 +56,11 @@ class DatabaseOperations(BaseDatabaseOperations):
|
||||||
'aggregations on date/time fields in sqlite3 '
|
'aggregations on date/time fields in sqlite3 '
|
||||||
'since date/time is saved as text.'
|
'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(
|
raise NotSupportedError(
|
||||||
"SQLite doesn't support DISTINCT on aggregate functions "
|
"SQLite doesn't support DISTINCT on aggregate functions "
|
||||||
"accepting multiple arguments."
|
"accepting multiple arguments."
|
||||||
|
|
|
@ -63,6 +63,15 @@ class Tests(TestCase):
|
||||||
with self.assertRaisesMessage(NotSupportedError, msg):
|
with self.assertRaisesMessage(NotSupportedError, msg):
|
||||||
connection.ops.check_expression_support(aggregate)
|
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):
|
def test_memory_db_test_name(self):
|
||||||
"""A named in-memory db should be allowed where supported."""
|
"""A named in-memory db should be allowed where supported."""
|
||||||
from django.db.backends.sqlite3.base import DatabaseWrapper
|
from django.db.backends.sqlite3.base import DatabaseWrapper
|
||||||
|
|
Loading…
Reference in New Issue