#33898: Broken usage of ArrayAgg inside Window function
-------------------------------------+-------------------------------------
Reporter: Kia | Owner: nobody
Type: Bug | Status: new
Component: Database | Version: 4.1
layer (models, ORM) |
Severity: Release | Keywords: ArrayAgg, Window
blocker | function, extend, tuple, params
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
The following query raises an AttributeError.
{{{
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.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/010701826e301f74-c34ead1e-2354-494d-84ff-35f5cf4da89a-000000%40eu-central-1.amazonses.com.