#33820: Querying "null" on key transforms for JSONField returns wrong results on
SQLite.
-------------------------------------+-------------------------------------
     Reporter:  Johnny Metz          |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  4.0
  (models, ORM)                      |
     Severity:  Release blocker      |               Resolution:
     Keywords:  JSONField            |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak):

 I tried to fix this few times in the last two weeks, unfortunately, I
 don't see a proper way to distinguish between `{"x": "null"}` and `{"x":
 NULL}` extracted from the JSON field (the same for boolean values). Mainly
 due to the lack of proper database types in SQLite. In
 71ec102b01fcc85acae3819426a4e02ef423b0fa we tried to use
 {{{#!sql
 CASE
     WHEN JSON_TYPE("model"."json_field", $."key") IN ('null', 'false',
 'true')
          THEN JSON_TYPE("model"."json_field", $."key")
     ELSE JSON_EXTRACT("model"."json_field", $."key")
 END
 }}}
 which fixed #32483 but also introduced this regression because for both
 `NULL` and `"null"` it returns `'null'`.

 Quo vadis? 🤷 We have two options:
 - document this as a SQLite caveat,
 - revert 71ec102b01fcc85acae3819426a4e02ef423b0fa and reintroduce another
 SQLite caveat.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/33820#comment:3>
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 on the web visit 
https://groups.google.com/d/msgid/django-updates/010701821b4aee99-207dfe12-7704-49a6-96d4-0a78edaa1588-000000%40eu-central-1.amazonses.com.

Reply via email to