mirror of
https://github.com/django/django.git
synced 2025-07-24 05:36:15 +00:00
Fixed #28658 -- Added DISTINCT handling to the Aggregate class.
This commit is contained in:
parent
222caab68a
commit
bc05547cd8
9 changed files with 83 additions and 24 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue