Contributor
Shafiya Adzhani

Add support for using key and path transforms in update() for JSONFields.


Mentors
Sage Abdullah
Organization
Django Software Foundation
Technologies
python, mysql, postgresql, django, sqlite, Oracle
Topics
web, database
The ticket-32159 (https://code.djangoproject.com/ticket/32519) originally requested a new feature to make Django provide generic database functions for manipulating JSON data on the database. Currently, in order to make partial updates to a JSONField, developers need tol oad model instance to the memory, modify JSONField data as objects, then call save() on the model instance, or write custom mapping for JSON functions as Func subclasses, and use them in update(). It would be better if Django has built-in support for doing partial JSONField updates more efficiently and more idiomatic to how developers can currently query JSONFields (i.e. with key transforms). In order to achieve that, this proposal intends to create an implementation for all databases supported that developers can use in order to update partial values of JSONField. This project aims to accomplish the problem by dividing it into two big parts: first, implement JSONSet and JSONRemove functions to allow partial updates to JSONField. Second, add support for key transforms in update() for JSONField to make it easier to use for developers. The project will be executed on creating JSONSet for SQLite, MySQL, PostgreSQL, Oracle first, then, create JSONRemove on same databases. After that, support for key transform on update() will be implemented.