#33820: Querying null in JSONField is different between 3.2 and 4.0
-------------------------------------+-------------------------------------
               Reporter:  Johnny     |          Owner:  nobody
  Metz                               |
                   Type:  Bug        |         Status:  new
              Component:  Database   |        Version:  4.0
  layer (models, ORM)                |
               Severity:  Normal     |       Keywords:  JSONField
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 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.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/33820>
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/01070181bcf5b169-956993eb-63b2-479d-9ca9-d6e470b69551-000000%40eu-central-1.amazonses.com.

Reply via email to