[Django] #36134: Add "ABSENT ON NULL" to JsonArray

17 views
Skip to first unread message

Django

unread,
Jan 23, 2025, 6:23:12 PMJan 23
to django-...@googlegroups.com
#36134: Add "ABSENT ON NULL" to JsonArray
-------------------------------------+-------------------------------------
Reporter: john-parton | Type: New
| feature
Status: new | Component: Database
| layer (models, ORM)
Version: dev | Severity: Normal
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
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.
--
Ticket URL: <https://code.djangoproject.com/ticket/36134>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jan 23, 2025, 6:25:11 PMJan 23
to django-...@googlegroups.com
#36134: Add "ABSENT ON NULL" to JsonArray
-------------------------------------+-------------------------------------
Reporter: john-parton | Owner: (none)
Type: New feature | Status: new
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Old description:

> 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.

New description:

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

--
Comment (by john-parton):

Pull Request here:
--
Ticket URL: <https://code.djangoproject.com/ticket/36134#comment:1>

Django

unread,
Jan 23, 2025, 6:42:48 PMJan 23
to django-...@googlegroups.com
#36134: Add "ABSENT ON NULL" to JsonArray
-------------------------------------+-------------------------------------
Reporter: john-parton | Owner: (none)
Type: New feature | Status: new
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Simon Charette):

* stage: Unreviewed => Accepted

Comment:

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.
--
Ticket URL: <https://code.djangoproject.com/ticket/36134#comment:2>

Django

unread,
Jan 23, 2025, 7:44:43 PMJan 23
to django-...@googlegroups.com
#36134: Add "ABSENT ON NULL" to JsonArray
-------------------------------------+-------------------------------------
Reporter: john-parton | Owner: (none)
Type: New feature | Status: new
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by john-parton):

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.
--
Ticket URL: <https://code.djangoproject.com/ticket/36134#comment:3>

Django

unread,
Jan 24, 2025, 1:12:51 AMJan 24
to django-...@googlegroups.com
#36134: Add "ABSENT ON NULL" to JsonArray
-------------------------------------+-------------------------------------
Reporter: john-parton | Owner: (none)
Type: New feature | Status: new
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by john-parton):

Note: My solution is only sort of straightforward now. I've added a
workaround to make MySQL and older versions of Postgres behave.
--
Ticket URL: <https://code.djangoproject.com/ticket/36134#comment:4>

Django

unread,
Jan 24, 2025, 1:44:16 AMJan 24
to django-...@googlegroups.com
#36134: Add "ABSENT ON NULL" to JsonArray
-------------------------------------+-------------------------------------
Reporter: john-parton | Owner: john-
| parton
Type: New feature | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Antoliny):

* owner: (none) => john-parton
* status: new => assigned

--
Ticket URL: <https://code.djangoproject.com/ticket/36134#comment:5>

Django

unread,
Apr 26, 2025, 7:43:28 AMApr 26
to django-...@googlegroups.com
#36134: Add "ABSENT ON NULL" to JsonArray
-------------------------------------+-------------------------------------
Reporter: john-parton | Owner: john-
| parton
Type: New feature | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Giannis Terzopoulos):

PR [https://github.com/django/django/pull/19101] incorrectly references
this ticket, it was for #36139 instead
--
Ticket URL: <https://code.djangoproject.com/ticket/36134#comment:6>

Django

unread,
May 26, 2025, 5:22:38 PMMay 26
to django-...@googlegroups.com
#36134: Add "ABSENT ON NULL" to JsonArray
-------------------------------------+-------------------------------------
Reporter: john-parton | Owner: john-
| parton
Type: New feature | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Simon Charette):

* needs_better_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/36134#comment:7>

Django

unread,
Jul 9, 2025, 1:33:15 AMJul 9
to django-...@googlegroups.com
#36134: Add "ABSENT ON NULL" to JsonArray
-------------------------------------+-------------------------------------
Reporter: john-parton | Owner: john-
| parton
Type: New feature | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by john-parton):

* needs_better_patch: 1 => 0

--
Ticket URL: <https://code.djangoproject.com/ticket/36134#comment:8>

Django

unread,
Jul 15, 2025, 10:17:29 AMJul 15
to django-...@googlegroups.com
#36134: Add "ABSENT ON NULL" to JsonArray
-------------------------------------+-------------------------------------
Reporter: john-parton | Owner: john-
| parton
Type: New feature | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce):

* needs_docs: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/36134#comment:9>
Reply all
Reply to author
Forward
0 new messages