#36139: Allow expressing JSONObject keys dynamically, as well as explicit pair-
values
-------------------------------------+-------------------------------------
     Reporter:  john-parton          |                    Owner:  john-
                                     |  parton
         Type:  New feature          |                   Status:  closed
    Component:  Database layer       |                  Version:  dev
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:  wontfix
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Description changed by john-parton:

Old description:

> In working towards supporting `ABSENT ON NULL` for JSONArray, I did some
> digging on what it would take to implement it for `JSONObject` as well,
> and essentially, because the __init__ signature consumes all the
> `kwargs`, there's not really a good way to configure its behavior without
> conflicting with a key definition.
>
> If you could specify the items of a JSONObject positionally, then you get
> the aforementioned benefit of being able to have kwargs as well without
> conflicting, but you also get the added benefit of being able to
> construct objects with non-static keys.
>
> As an example esoteric usage, if you're trying to get the database to
> omit valid objects for the Elasticsearch DSL, you would almost certainly
> need to be able to build objects with non-static keys.
>
> For example
> https://www.elastic.co/guide/en/elasticsearch/reference/current/query-
> dsl-term-query.html
>
> The key "user.id" refers to a field in elastic.
>
> See some discussion here:
> https://github.com/django/django/pull/19097#issuecomment-2611270246
>
> I'll throw together a patch.

New description:

 Currently there is no way to build a JSON object in the database using the
 JSONObject function where the keys are anything but static keys.

 This is not a limitation of any of the backends that support JSON objects.

 If you could specify the items of a JSONObject positionally, you get the
 benefit of being able to construct objects with non-static keys.

 As an example esoteric usage, if you're trying to get the database to emit
 valid objects for the Elasticsearch DSL, you would almost certainly need
 to be able to build objects with non-static keys.

 For example
 https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-
 term-query.html

 The key "user.id" refers to a field in elastic.

 See some discussion here:
 https://github.com/django/django/pull/19097#issuecomment-2611270246

 I'll throw together a patch.

--
-- 
Ticket URL: <https://code.djangoproject.com/ticket/36139#comment:7>
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 visit 
https://groups.google.com/d/msgid/django-updates/01070194d1ef0e29-35bcb41e-18d6-41fb-ac0e-9af4e23eaf3c-000000%40eu-central-1.amazonses.com.

Reply via email to