mirror of
https://github.com/django/django.git
synced 2025-07-24 05:36:15 +00:00
Fixed #26617 -- Added distinct argument to contrib.postgres's StringAgg.
This commit is contained in:
parent
149ace94df
commit
df8412d2e5
4 changed files with 33 additions and 5 deletions
|
@ -111,6 +111,24 @@ class TestGeneralAggregate(PostgreSQLTestCase):
|
|||
self.assertEqual(values, {'stringagg': ''})
|
||||
|
||||
|
||||
class TestStringAggregateDistinct(PostgreSQLTestCase):
|
||||
@classmethod
|
||||
def setUpTestData(cls):
|
||||
AggregateTestModel.objects.create(char_field='Foo')
|
||||
AggregateTestModel.objects.create(char_field='Foo')
|
||||
AggregateTestModel.objects.create(char_field='Bar')
|
||||
|
||||
def test_string_agg_distinct_false(self):
|
||||
values = AggregateTestModel.objects.aggregate(stringagg=StringAgg('char_field', delimiter=' ', distinct=False))
|
||||
self.assertEqual(values['stringagg'].count('Foo'), 2)
|
||||
self.assertEqual(values['stringagg'].count('Bar'), 1)
|
||||
|
||||
def test_string_agg_distinct_true(self):
|
||||
values = AggregateTestModel.objects.aggregate(stringagg=StringAgg('char_field', delimiter=' ', distinct=True))
|
||||
self.assertEqual(values['stringagg'].count('Foo'), 1)
|
||||
self.assertEqual(values['stringagg'].count('Bar'), 1)
|
||||
|
||||
|
||||
class TestStatisticsAggregate(PostgreSQLTestCase):
|
||||
@classmethod
|
||||
def setUpTestData(cls):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue