Opened 5 months ago

Closed 5 months ago

Last modified 5 months ago

#30332 closed Bug (fixed)

Postgres ordering ARRAY_AGG and STRING_AGG do not support expression.

Reported by: Simone Pellizzari Owned by: Simone Pellizzari
Component: Database layer (models, ORM) Version: 2.2
Severity: Release blocker Keywords: postgres string_agg array_agg ordering order by
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Simone Pellizzari)

I found that if you pass and expression as an ordering argument (introduced in https://github.com/django/django/commit/96199e562dcc409ab4bdc2b2146fa7cf73c7c5fe) an IndexError: tuple index out of range exception will be thrown when the query is executed.

This is caused by simply ignoring sql_params returned from as_sql calls on expressions contained built from ordering argument.

Change History (9)

comment:1 Changed 5 months ago by Simone Pellizzari

Description: modified (diff)

comment:2 Changed 5 months ago by Simone Pellizzari

Owner: changed from nobody to Simone Pellizzari
Status: newassigned

comment:3 Changed 5 months ago by Simone Pellizzari

Resolution: fixed
Status: assignedclosed

Opened a pull request that solves this: https://github.com/django/django/pull/11172

Last edited 5 months ago by Simone Pellizzari (previous) (diff)

comment:4 Changed 5 months ago by Simone Pellizzari

Description: modified (diff)

comment:5 Changed 5 months ago by Simone Pellizzari

Resolution: fixed
Status: closednew

Ahem, just wanted to marked as resolved by linked pull request...didn't really want to close :-)

comment:6 Changed 5 months ago by Simone Pellizzari

Status: newassigned

comment:7 Changed 5 months ago by felixxm

Severity: NormalRelease blocker
Triage Stage: UnreviewedAccepted

Marked as a release blocker because it is a bug in a new feature introduced in Django 2.2.

comment:8 Changed 5 months ago by Mariusz Felisiak <felisiak.mariusz@…>

Resolution: fixed
Status: assignedclosed

In d0315584:

Fixed #30332 -- Fixed crash of ordering by expressions with params in ArrayAgg and StringAgg.

comment:9 Changed 5 months ago by Mariusz Felisiak <felisiak.mariusz@…>

In 268ed9cd:

[2.2.x] Fixed #30332 -- Fixed crash of ordering by expressions with params in ArrayAgg and StringAgg.

Backport of d0315584b5ed6a47b486e65f6c88f80189f337ef from master.

Note: See TracTickets for help on using tickets.
Back to Top