#35381: Provide `JSONNull` expression to represent JSON `null` value
-------------------------------------+-------------------------------------
     Reporter:  Olivier Tabone       |                    Owner:  Clifford
                                     |  Gama
         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
-------------------------------------+-------------------------------------
Comment (by Clifford Gama):

 I’d like clarification on whether we also want to deprecate
 `filter(data__key=None)`.

 As I understand it, the ambiguity motivating deprecation at the top level
 does not exist inside a JSON document. A key’s value can be JSON `null`,
 but it cannot be SQL `NULL`. For that reason, I think
 filter(data__key=None) should continue to match JSON `null`.

 We could still allow `.filter(data__key=JSONNull())` for users who want
 explicitness, without deprecating `None` usage in this case, especially as
 Jacob pointed out, this case is more common. Additionally, on the creation
 side, supporting nested JSON null like {"key": JSONNull()} in
 inserts/updates would require a custom encoder, which isn’t the case for
 `JSONNull()` at the top level. Since users can already override
 encoders/decoders, we can’t make that work universally. We could bypass
 this problem by introducing and promoting (in the docs) the use of
 `__is_jsonnull` lookup for querying and JSONNull() for creating top-level
 JSON `null`.

 If we don’t deprecate using `None` in `KeyTransform` lookups to mean JSON
 null, then ticket #36508 would have to be reopened, as it is surprising
 that `(jsonfield__key__iexact=None)` is translated to an `__isnull` lookup
 when `jsonfield__key=None` means "does key have a value of JSON `null`."
-- 
Ticket URL: <https://code.djangoproject.com/ticket/35381#comment:18>
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 visit 
https://groups.google.com/d/msgid/django-updates/01070198e0c33a17-f117b603-d98e-4ee0-9d53-91e6b8274a01-000000%40eu-central-1.amazonses.com.

Reply via email to