{{{
class Event(models.Model):
data = models.JSONField()
}}}
And I create the following objects:
{{{
event1 = Event.objects.create(data={"key": None})
event2 = Event.objects.create(data={"key": "null"})
}}}
In Django 3.2.13, the following queries return some results:
{{{
Event.objects.filter(data__key=Value("null"))
# [event1]
Event.objects.filter(data__key="null")
# [event2]
}}}
In Django 4.0.5, the same queries return different results:
{{{
Event.objects.filter(data__key=Value("null"))
# [event1, event2]
Event.objects.filter(data__key="null")
# [event1, event2]
}}}
The [https://docs.djangoproject.com/en/4.0/topics/db/queries/#querying-
jsonfield Django docs] aren't clear which results are correct. I would
lean towards the v3 results.
I'm happy to work on a patch if people think this is a bug in v4.
--
Ticket URL: <https://code.djangoproject.com/ticket/33820>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.