#35462: Add support JSONArrayAgg
-------------------------------------+-------------------------------------
     Reporter:  Robert Silén         |                    Owner:  nobody
         Type:  New feature          |                   Status:  new
    Component:  Database layer       |                  Version:  5.0
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:  aggregation,         |             Triage Stage:  Accepted
  ArrayAgg                           |
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Simon Charette):

 * component:  Uncategorized => Database layer (models, ORM)
 * stage:  Unreviewed => Accepted
 * summary:  ArrayAgg and others for MariaDB => Add support JSONArrayAgg

Comment:

 The `contrib.postgres.ArrayAgg` expression you pointed at uses Postgres
 arrays and MariaDB doesn't have native array support so they are not
 equivalent.

 `JSON_ARRAYAGG` is a standard SQL function implemented on Postgres,
 SQLite, MySQL, SQLite, Oracle, and MariaDB so if we were to include it in
 core it should be for all supported backends and not only for MariaDB.

 It should be trivial to implement by subclassing `Aggregate` in fact I
 suspect that the following should work on most backends by default

 {{{#!python
 class JSONArrayAgg(Aggregate):
     function = "JSON_ARRAYAGG"
     output_field = JSONField()
     arity = 1
 }}}

 Or with subtle adjusted as using `json_group_array` on SQLite.

 As for `StringAgg` with a fallback on `GROUP_CONCAT` on MySQL and MariaDB
 it is already being explored in #35444 which plans to add support for
 configurable support for `ORDER BY` in aggregates.
-- 
Ticket URL: <https://code.djangoproject.com/ticket/35462#comment:3>
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018f86db196d-8dee4243-d7cc-408d-9a52-714ffe588318-000000%40eu-central-1.amazonses.com.

Reply via email to