diff options
author | Simon Charette <charettes@users.noreply.github.com> | 2019-01-09 17:52:36 -0500 |
---|---|---|
committer | Tim Graham <timograham@gmail.com> | 2019-01-09 17:52:36 -0500 |
commit | bc05547cd8c1dd511c6b6a6c873a1bc63417b111 (patch) | |
tree | 2ba1a136e77b21df2524d5558ea0a6f25d5ff03b /tests/aggregation_regress | |
parent | 222caab68a2a7345043d0c50161203cb2cfe70eb (diff) | |
download | django-bc05547cd8c1dd511c6b6a6c873a1bc63417b111.tar.gz |
Fixed #28658 -- Added DISTINCT handling to the Aggregate class.
Diffstat (limited to 'tests/aggregation_regress')
-rw-r--r-- | tests/aggregation_regress/tests.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/aggregation_regress/tests.py b/tests/aggregation_regress/tests.py index 29b32c4987..2b3948a0b4 100644 --- a/tests/aggregation_regress/tests.py +++ b/tests/aggregation_regress/tests.py @@ -11,6 +11,7 @@ from django.db.models import ( Avg, Case, Count, DecimalField, F, IntegerField, Max, Q, StdDev, Sum, Value, Variance, When, ) +from django.db.models.aggregates import Aggregate from django.test import ( TestCase, ignore_warnings, skipUnlessAnyDBFeature, skipUnlessDBFeature, ) @@ -1496,6 +1497,16 @@ class AggregationTests(TestCase): qs = Author.objects.values_list('age', flat=True).annotate(age_count=Count('age')).filter(age_count__gt=1) self.assertSequenceEqual(qs, [29]) + def test_allow_distinct(self): + class MyAggregate(Aggregate): + pass + with self.assertRaisesMessage(TypeError, 'MyAggregate does not allow distinct'): + MyAggregate('foo', distinct=True) + + class DistinctAggregate(Aggregate): + allow_distinct = True + DistinctAggregate('foo', distinct=True) + class JoinPromotionTests(TestCase): def test_ticket_21150(self): |