#32776: Support Array subqueries on PostgreSQL
-------------------------------------+-------------------------------------
Reporter: Hannes | Owner: Hannes Ljungberg
Ljungberg |
Type: New | Status: assigned
feature |
Component: | Version: dev
contrib.postgres |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
I think we should support [https://www.postgresql.org/docs/current/sql-
expressions.html#SQL-SYNTAX-ARRAY-CONSTRUCTORS constructing arrays in
PostgreSQL]() without requiring aggregation through `array_agg()`. This
can be done by correlated subqueries by passing a subquery to the `ARRAY`
constructor. In its simplest form it could look something like this:
{{{
class ArraySubquery(Subquery):
template = 'ARRAY(%(subquery)s)'
}}}
Currently all subqueries get their ordering cleared if they aren't
fulfilling some conditions like being sliced and using distinct fields.
This would need to be refactored to enable array subqueries since the
ordering matters due to the subquery producing an array.
There've been a couple of tickets related to this:
https://code.djangoproject.com/ticket/31687
https://code.djangoproject.com/ticket/32658
[https://code.djangoproject.com/ticket/32658#comment:4 Simons suggestion]
to move the clearing of ordering from `Query.resolve_expression` to
`In(Lookup).process_rhs` seems like a good idea to me.
I also think that adding support for array subqueries would help in
resolving this ticket: https://code.djangoproject.com/ticket/26056
--
Ticket URL: <https://code.djangoproject.com/ticket/32776>
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/052.2e83cc12d0a8c184f584f3c4d3428235%40djangoproject.com.