Opened 10 hours ago
Last modified 3 hours ago
#36134 assigned New feature
Add "ABSENT ON NULL" to JsonArray
Reported by: | john-parton | Owned by: | john-parton |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
On all backends except Sqlite and Postgres version 15 and earlier, there is an additional clause to the JSON_ARRAY SQL which controls whether SQL NULL values are mapped to JSON null values or whether they are omitted.
In sqlite and postgres 15 and earlier, the default behavior is to map them, so my initial feature for JsonArray just had that as the only behavior without any ability to customize on the richer backends.
It would be nice if there was a simple on_null
parameter to JSON ARRAY to control the behavior.
Pull request here: https://github.com/django/django/pull/19097
Change History (5)
comment:1 by , 10 hours ago
Description: | modified (diff) |
---|
comment:2 by , 10 hours ago
Triage Stage: | Unreviewed → Accepted |
---|
What do to of nulls was a point of discussion when the JSONArray
feature was added so supporting either mode, when the backends allows, seems like a valuable feature.
FWIW it's also something that was discussed in the design of JSONArrayAgg
#35462.
comment:3 by , 9 hours ago
I think my solution is pretty straightforward, actually. if we'd rather centralize discussion there, we can. I think the only real coordination would be on the feature bool.
comment:4 by , 4 hours ago
Note: My solution is only sort of straightforward now. I've added a workaround to make MySQL and older versions of Postgres behave.
comment:5 by , 3 hours ago
Owner: | set to |
---|---|
Status: | new → assigned |
Pull Request here: https://github.com/django/django/pull/19097