{{{
from django.contrib.postgres.aggregates import ArrayAgg
from django.db.models.expressions import Window
SampleModel.objects.all().annotate(
sample_field=Window(
expression=ArrayAgg("field_three"),
partition_by=["field_one", "field_two"],
)
)
}}}
Traceback:
{{{
File "/usr/local/lib/python3.10/site-
packages/django/db/models/expressions.py", line 1693, in as_sql
params.extend(window_params)
AttributeError: 'tuple' object has no attribute 'extend'
}}}
Works in Django 4.0.6 (maybe even in 4.0.7, didn't try) but broken in
Django 4.1.
Seems like in OrderableAggMixin
(https://github.com/django/django/blob/4.1/django/contrib/postgres/aggregates/mixins.py#L23)
it used to return a `list` as second value, but now it's a `tuple` that
breaks `params.extend()` in
https://github.com/django/django/blob/4.1/django/db/models/expressions.py#L1693
--
Ticket URL: <https://code.djangoproject.com/ticket/33898>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.