mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
Fixed #28658 -- Added DISTINCT handling to the Aggregate class.
This commit is contained in:
committed by
Tim Graham
parent
222caab68a
commit
bc05547cd8
@@ -4,6 +4,7 @@ import unittest
|
||||
|
||||
from django.db import connection, transaction
|
||||
from django.db.models import Avg, StdDev, Sum, Variance
|
||||
from django.db.models.aggregates import Aggregate
|
||||
from django.db.models.fields import CharField
|
||||
from django.db.utils import NotSupportedError
|
||||
from django.test import (
|
||||
@@ -34,6 +35,17 @@ class Tests(TestCase):
|
||||
**{'complex': aggregate('last_modified') + aggregate('last_modified')}
|
||||
)
|
||||
|
||||
def test_distinct_aggregation(self):
|
||||
class DistinctAggregate(Aggregate):
|
||||
allow_distinct = True
|
||||
aggregate = DistinctAggregate('first', 'second', distinct=True)
|
||||
msg = (
|
||||
"SQLite doesn't support DISTINCT on aggregate functions accepting "
|
||||
"multiple arguments."
|
||||
)
|
||||
with self.assertRaisesMessage(NotSupportedError, msg):
|
||||
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