1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #32169 -- Added distinct support to JSONBAgg.

This commit is contained in:
Artur Beltsov
2020-11-04 16:30:47 +05:00
committed by Mariusz Felisiak
parent c36075ac1d
commit 18c8ced81e
4 changed files with 25 additions and 2 deletions

View File

@@ -428,6 +428,18 @@ class TestAggregateDistinct(PostgreSQLTestCase):
values = AggregateTestModel.objects.aggregate(arrayagg=ArrayAgg('char_field', distinct=True))
self.assertEqual(sorted(values['arrayagg']), ['Bar', 'Foo'])
def test_json_agg_distinct_false(self):
values = AggregateTestModel.objects.aggregate(
jsonagg=JSONBAgg('char_field', distinct=False),
)
self.assertEqual(sorted(values['jsonagg']), ['Bar', 'Foo', 'Foo'])
def test_json_agg_distinct_true(self):
values = AggregateTestModel.objects.aggregate(
jsonagg=JSONBAgg('char_field', distinct=True),
)
self.assertEqual(sorted(values['jsonagg']), ['Bar', 'Foo'])
class TestStatisticsAggregate(PostgreSQLTestCase):
@classmethod