#35718: Some useful postgres functions for JSON are missing from contrib
----------------------------------+---------------------------------------
     Reporter:  john-parton       |                    Owner:  john-parton
         Type:  New feature       |                   Status:  assigned
    Component:  contrib.postgres  |                  Version:  dev
     Severity:  Normal            |               Resolution:
     Keywords:                    |             Triage Stage:  Unreviewed
    Has patch:  1                 |      Needs documentation:  1
  Needs tests:  1                 |  Patch needs improvement:  1
Easy pickings:  0                 |                    UI/UX:  0
----------------------------------+---------------------------------------
Description changed by john-parton:

Old description:

> There's a large number of postgres-specific functions for manipulating
> json: https://www.postgresql.org/docs/current/functions-json.html
>
> In my projects for work, I have created several:
>
> * jsonb_build_object
> * jsonb_build_array
> * jsonb_array_elements
> * jsonb_extract_path
> * jsonb_extract_path_text
> * jsonb_array_length
>
> It would be nice if these were included in `contrib.postgres.functions`,
> ideally in a submodule like `contrib.postgres.function.json` to allow
> room to expand.
>
> I know postgres's json support is a bit of test-bed for more fleshed out
> json support in general, but I would recommend just adding things as
> postgres-specific to limit the scope of the changes.
>
> I can open a basic pull request.

New description:

 There's a large number of postgres-specific functions for manipulating
 json: https://www.postgresql.org/docs/current/functions-json.html

 In my projects for work, I have created several:

 * ~~jsonb_build_object~~ -- Actually already implemented as
 `django.db.models.functions.JSONObject`
 * jsonb_build_array
 * jsonb_array_elements
 * ~~jsonb_extract_path~~ Functionally equivalent to the `#>` operator
 * ~~jsonb_extract_path_text~~ Functionally equivalent to the `#>>`
 operator
 * jsonb_array_length

 There also a few operators that I implemented as django functions

 * jsonb || jsonb -> jsonb - Concatenates two jsonb values
 * jsonb - text -> jsonb - Deletes a key (and its value) from a JSON object

 It would be nice if these were included in `contrib.postgres.functions`,
 ideally in a submodule like `contrib.postgres.function.json` to allow room
 to expand.

 I know postgres's json support is a bit of test-bed for more fleshed out
 json support in general, but I would recommend just adding things as
 postgres-specific to limit the scope of the changes.

 I can open a basic pull request.

--
-- 
Ticket URL: <https://code.djangoproject.com/ticket/35718#comment:6>
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/01070191a167d175-ac9ceca3-c8ab-4014-a3df-c32d050cb518-000000%40eu-central-1.amazonses.com.

Reply via email to