#26327: JSON_AGG aggregate for PostgreSQL ----------------------------------+------------------------------------- Reporter: tomaszn | Owner: Type: New feature | Status: new Component: contrib.postgres | Version: Severity: Normal | Keywords: JSON postgres aggregate Triage Stage: Unreviewed | Has patch: 1 Easy pickings: 0 | UI/UX: 0 ----------------------------------+------------------------------------- PostgreSQL 9.3 added many features for the JSON data type. They include JSON_AGG aggregate, which could join its friends (ArrayAgg and StringAgg) in django/contrib/postgres/aggregates/general.py, please find draft implementation. Function description: http://www.postgresql.org/docs/9.3/static/functions- aggregate.html
Other (non-aggregate) functions and expressions could go to a new file, maybe django/contrib/postgres/expressions.py? Please find attached JSON_BUILD_OBJECT implementation. It takes an array of column names and converts it to alternating key/value pairs for the function; the key is an extracted column name. It works for me, but I guess the column name (the key) should be somehow sanitized before appending to sql_expressions. -- Ticket URL: <https://code.djangoproject.com/ticket/26327> 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 post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/050.2f76f87b298edb76f53eda85ad6162ff%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.