mirror of
https://github.com/django/django.git
synced 2025-10-06 08:40:42 +00:00
[4.1.x] Fixed #33898 -- Fixed Window() expression crash with ArrayAgg().
Thanks Kia for the report. Regression ine06dc4571e
. Backport offd93db97c7
from main
This commit is contained in:
parent
d3ef502aa9
commit
d9ace347b4
3 changed files with 26 additions and 6 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue