#32519: Add support for using key and path transforms in update() for
JSONFields.
-------------------------------------+-------------------------------------
Reporter: Baptiste Mispelon | Owner: allen-
| munsch
Type: New feature | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by allen-munsch):
* owner: nobody => allen-munsch
* status: new => assigned
Comment:
I have a draft PR currently open with a first attempt here:
* https://github.com/django/django/pull/15422
It currently has tests for sqlite and postgresql.
I think there is room for improvement in the signature, as their is a
kwarg that seems like it would be redundant.
For example the usage of "some_json_field" here:
# sqlite
queryset.update(some_json_field=JSONSet(field="some_json_field",
fields={"$.item_in_json_field": Value("asdf")}))
# postgresql
queryset.update(some_json_field=JSONSet(field="some_json_field",
fields={"{item_in_json_field}": Value('"asdf"')}))
There's also some backend vendor specific wonkiness on `F()`s and
`Value`s, and all of the cases on oracle for the op type.
I'm hoping to continue work on it this week and next.
My thinking currently is that it would be possible to connect JSONSet into
the JSONFields update key and transforms ( although I don't know what the
key and transform code looks like currently, and was going to look into
that this week)
Depending on direction from the core maintainers I could also attempt to
include a JSONRemove util, either in the same PR, or in a separate one.
--
Ticket URL: <https://code.djangoproject.com/ticket/32519#comment:5>
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/067.289deea7374ad38dc89f04553b8c9e97%40djangoproject.com.