#32078: Inconsistent JSONField filtering for value None
-------------------------------------+-------------------------------------
Reporter: fre-db | Owner: nobody
Type: Uncategorized | Status: closed
Component: Database layer | Version: 3.1
(models, ORM) | Resolution:
Severity: Normal | worksforme
Keywords: JSONField, None | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):
* status: new => closed
* resolution: => worksforme
Comment:
It works as expected for me:
{{{
>>> NullableJSONModel.objects.create(value={'key': None})
NullableJSONModel object (14)
>>> NullableJSONModel.objects.filter(value__key=None)
<QuerySet [<NullableJSONModel: NullableJSONModel object (14)>]>
>>> NullableJSONModel.objects.filter(value__key__isnull=True) # This will
return also JSONFields without the `key`.
<QuerySet [<NullableJSONModel: NullableJSONModel object (14)>]>
>>> NullableJSONModel.objects.filter(value__key__in=[None])
<QuerySet []>
}}}
See [https://docs.djangoproject.com/en/3.1/topics/db/queries/#storing-and-
querying-for-none "Storing and querying for None"] and
[https://docs.djangoproject.com/en/3.1/topics/db/queries/#key-index-and-
path-transforms "Key, index, and path transforms"] docs.
--
Ticket URL: <https://code.djangoproject.com/ticket/32078#comment:1>
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/064.c340b988fa8cb2597422d4db976eabb6%40djangoproject.com.