﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
33820	"Querying ""null"" on key transforms for JSONField returns wrong results on SQLite."	Johnny Metz	Mariusz Felisiak	"Let's say I have a Django model with a `JSONField`:

{{{
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."	Bug	closed	Database layer (models, ORM)	4.0	Release blocker	fixed	JSONField	Matthew Cornell Sage Abdullah	Accepted	1	0	0	0	0	0
