#36508: Asymmetry between exact and iexact when filtering JSON keys against None
-------------------------------------+-------------------------------------
Reporter: Jacob Walls | Owner: (none)
Type: Bug | Status: new
Component: Database layer | Version: 5.2
(models, ORM) |
Severity: Normal | Resolution:
Keywords: null, jsonfield | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sage Abdullah):
* cc: Sage Abdullah (added)
* resolution: duplicate =>
* status: closed => new
Comment:
With the discussion in #35381, I think this is a separate issue. The main
reason behind adding a `JSONNull()` that resulted in the creation of that
ticket is for addressing the ambiguity of top-level values. Even if #35381
also adds support for using `json__key=JSONNull()` (at least in the
querying case), it's clear that we do want to keep `json__key=None` to
match JSON `null` in both querying and storing cases.
If #35381 is addressed, I imagine the
[
https://github.com/django/django/blob/3e7aedfb2eb37d0c83ce3ce936f1b89eb5451dfa/django/db/models/fields/json.py#L318-L320
code that handles] `None` in `JSONExact` will be replaced with a
`JSONNull` check. Then, the `can_use_none_as_rhs` probably needs to be
moved from `JSONExact` to `KeyTransformExact`.
However, it's likely `KeyTransformIExact` will need the same treatment, as
it currently only extends `CaseInsensitiveMixin,
KeyTransformTextLookupMixin, lookups.IExact` without additional code. We
might need to refactor `KeyTransformExact` so that some of its code can be
reused by `KeyTransformIExact`. From a quick guess, these changes seem
isolated to #35381.
--
Ticket URL: <
https://code.djangoproject.com/ticket/36508#comment:5>