Opened 9 months ago
Last modified 2 months ago
#35462 assigned New feature
Add support JSONArrayAgg
Description (last modified by ) ¶
I suggest to add ArrayAgg and related (aggregation) functions for MariaDB to Django. It has been noted in MariaDB Foundation ticket: https://jira.mariadb.org/browse/MDBF-690
E.g. ArrayAgg is mentioned on PostgreSQL specific aggregation functions:
https://docs.djangoproject.com/en/dev/ref/contrib/postgres/aggregates/#arrayagg
The equivalent in MariaDB is presumably this:
https://mariadb.com/kb/en/json_arrayagg/
More equivalent MariaDB aggregate functions are listed at the following address.
https://mariadb.com/kb/en/aggregate-functions/
Some have same name 1:1. I'm guessing e.g. StringAgg could be done with GROUP_CONCAT.
Feel free to ask more here, or in the MariaDB Foundation ticket.
According to the ticket's flags, the next step(s) to move this issue forward are:
- To improve the patch as described in the pull request review comments or on this ticket, then uncheck "Patch needs improvement".
If creating a new pull request, include a link to the pull request in the ticket comment when making that update. The usual format is:
[https://github.com/django/django/pull/#### PR]
.
Change History (13)
comment:1 by , 9 months ago
Description: | modified (diff) |
---|
comment:2 by , 9 months ago
Description: | modified (diff) |
---|
comment:3 by , 9 months ago
Component: | Uncategorized → Database layer (models, ORM) |
---|---|
Summary: | ArrayAgg and others for MariaDB → Add support JSONArrayAgg |
Triage Stage: | Unreviewed → Accepted |
comment:4 by , 8 months ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:5 by , 8 months ago
Cc: | added |
---|
comment:7 by , 7 months ago
Needs documentation: | set |
---|
comment:8 by , 7 months ago
Needs tests: | set |
---|---|
Patch needs improvement: | set |
comment:9 by , 5 months ago
Needs documentation: | unset |
---|---|
Needs tests: | unset |
Patch needs improvement: | unset |
comment:10 by , 4 months ago
Patch needs improvement: | set |
---|
comment:11 by , 3 months ago
Patch needs improvement: | unset |
---|
comment:12 by , 2 months ago
Cc: | added |
---|
comment:13 by , 2 months ago
Patch needs improvement: | set |
---|
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 defaultOr with subtle adjusted as using
json_group_array
on SQLite.As for
StringAgg
with a fallback onGROUP_CONCAT
on MySQL and MariaDB it is already being explored in #35444 which plans to add support for configurable support forORDER BY
in aggregates.