diff options
author | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2022-08-06 17:59:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-06 17:59:31 +0200 |
commit | fd93db97c7228b16a4f92f97ef05b0d72418d952 (patch) | |
tree | d23a5c27270ea655faea558bee53cec2c8117d33 /tests/postgres_tests | |
parent | 00370342ca3a478660372975b3309ffc4d535be1 (diff) | |
download | django-fd93db97c7228b16a4f92f97ef05b0d72418d952.tar.gz |
Fixed #33898 -- Fixed Window() expression crash with ArrayAgg().
Thanks Kia for the report.
Regression in e06dc4571ea9fd5723c8029959b95808be9f8812.
Diffstat (limited to 'tests/postgres_tests')
-rw-r--r-- | tests/postgres_tests/test_aggregates.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/postgres_tests/test_aggregates.py b/tests/postgres_tests/test_aggregates.py index c3df490fcf..c2f38e42b6 100644 --- a/tests/postgres_tests/test_aggregates.py +++ b/tests/postgres_tests/test_aggregates.py @@ -8,6 +8,7 @@ from django.db.models import ( Q, Subquery, Value, + Window, ) from django.db.models.fields.json import KeyTextTransform, KeyTransform from django.db.models.functions import Cast, Concat, Substr @@ -669,6 +670,22 @@ class TestGeneralAggregate(PostgreSQLTestCase): inner_qs.values_list("integer_field", flat=True), ) + def test_window(self): + self.assertCountEqual( + AggregateTestModel.objects.annotate( + integers=Window( + expression=ArrayAgg("char_field"), + partition_by=F("integer_field"), + ) + ).values("integers", "char_field"), + [ + {"integers": ["Foo1", "Foo3"], "char_field": "Foo1"}, + {"integers": ["Foo1", "Foo3"], "char_field": "Foo3"}, + {"integers": ["Foo2"], "char_field": "Foo2"}, + {"integers": ["Foo4"], "char_field": "Foo4"}, + ], + ) + class TestAggregateDistinct(PostgreSQLTestCase): @classmethod |