mirror of
https://github.com/django/django.git
synced 2025-07-28 23:54:02 +00:00
Fixed #33114 -- Defined default output_field of StringAgg.
Thanks Simon Charette for the review.
This commit is contained in:
parent
8036b53de6
commit
ca58378390
4 changed files with 21 additions and 2 deletions
|
@ -25,22 +25,30 @@ class TestGeneralAggregate(PostgreSQLTestCase):
|
|||
@classmethod
|
||||
def setUpTestData(cls):
|
||||
cls.aggs = AggregateTestModel.objects.bulk_create([
|
||||
AggregateTestModel(boolean_field=True, char_field='Foo1', integer_field=0),
|
||||
AggregateTestModel(
|
||||
boolean_field=True,
|
||||
char_field='Foo1',
|
||||
text_field='Text1',
|
||||
integer_field=0,
|
||||
),
|
||||
AggregateTestModel(
|
||||
boolean_field=False,
|
||||
char_field='Foo2',
|
||||
text_field='Text2',
|
||||
integer_field=1,
|
||||
json_field={'lang': 'pl'},
|
||||
),
|
||||
AggregateTestModel(
|
||||
boolean_field=False,
|
||||
char_field='Foo4',
|
||||
text_field='Text4',
|
||||
integer_field=2,
|
||||
json_field={'lang': 'en'},
|
||||
),
|
||||
AggregateTestModel(
|
||||
boolean_field=True,
|
||||
char_field='Foo3',
|
||||
text_field='Text3',
|
||||
integer_field=0,
|
||||
json_field={'breed': 'collie'},
|
||||
),
|
||||
|
@ -299,6 +307,12 @@ class TestGeneralAggregate(PostgreSQLTestCase):
|
|||
values = AggregateTestModel.objects.aggregate(stringagg=StringAgg('char_field', delimiter=';'))
|
||||
self.assertEqual(values, {'stringagg': 'Foo1;Foo2;Foo4;Foo3'})
|
||||
|
||||
def test_string_agg_default_output_field(self):
|
||||
values = AggregateTestModel.objects.aggregate(
|
||||
stringagg=StringAgg('text_field', delimiter=';'),
|
||||
)
|
||||
self.assertEqual(values, {'stringagg': 'Text1;Text2;Text4;Text3'})
|
||||
|
||||
def test_string_agg_charfield_ordering(self):
|
||||
ordering_test_cases = (
|
||||
(F('char_field').desc(), 'Foo4;Foo3;Foo2;Foo1'),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue