mirror of
https://github.com/django/django.git
synced 2025-08-03 10:34:04 +00:00
Fixed #27767 -- Added distinct argument to ArrayAgg.
This commit is contained in:
parent
245f209109
commit
b5393028bf
5 changed files with 25 additions and 3 deletions
|
@ -128,7 +128,7 @@ class TestGeneralAggregate(PostgreSQLTestCase):
|
|||
self.assertEqual(values, json.loads('{"jsonagg": []}'))
|
||||
|
||||
|
||||
class TestStringAggregateDistinct(PostgreSQLTestCase):
|
||||
class TestAggregateDistinct(PostgreSQLTestCase):
|
||||
@classmethod
|
||||
def setUpTestData(cls):
|
||||
AggregateTestModel.objects.create(char_field='Foo')
|
||||
|
@ -145,6 +145,14 @@ class TestStringAggregateDistinct(PostgreSQLTestCase):
|
|||
self.assertEqual(values['stringagg'].count('Foo'), 1)
|
||||
self.assertEqual(values['stringagg'].count('Bar'), 1)
|
||||
|
||||
def test_array_agg_distinct_false(self):
|
||||
values = AggregateTestModel.objects.aggregate(arrayagg=ArrayAgg('char_field', distinct=False))
|
||||
self.assertEqual(sorted(values['arrayagg']), ['Bar', 'Foo', 'Foo'])
|
||||
|
||||
def test_array_agg_distinct_true(self):
|
||||
values = AggregateTestModel.objects.aggregate(arrayagg=ArrayAgg('char_field', distinct=True))
|
||||
self.assertEqual(sorted(values['arrayagg']), ['Bar', 'Foo'])
|
||||
|
||||
|
||||
class TestStatisticsAggregate(PostgreSQLTestCase):
|
||||
@classmethod
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue