Re: [Django] #32078: Inconsistent JSONField filtering for value None

2 views
Skip to first unread message

Django

unread,
Oct 7, 2020, 4:35:11 AM10/7/20
to django-...@googlegroups.com
#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.

Reply all
Reply to author
Forward
0 new messages