#34641: Null value referenced from a JSONField using an expression that defines 
an
output_field returns the string "null" instead of a None value
-------------------------------------------+------------------------
               Reporter:  Daniel Schaffer  |          Owner:  nobody
                   Type:  Bug              |         Status:  new
              Component:  Uncategorized    |        Version:  3.2
               Severity:  Normal           |       Keywords:
           Triage Stage:  Unreviewed       |      Has patch:  0
    Needs documentation:  0                |    Needs tests:  0
Patch needs improvement:  0                |  Easy pickings:  0
                  UI/UX:  0                |
-------------------------------------------+------------------------
 Example of breaking code:


 {{{
 class ThisHasAJSONField(Model):
     data = JSONField(null=True, blank=True, default=dict)

 ThisHasAJSONField.objects.create(data=dict(test=None))

 qs = ThisHasAJSONField.objects.annotate(
             test=Case(
                 When(id__isnull=True, then=F("data__test")),
                 default=F("data__test"),
                 output_field=IntegerField(null=True),
             )
         )
 }}}

 When referencing a null value using a JSON lookup from an expression that
 defines an `output_field`, the null value is converted to the string
 "null" instead of being treated as a `None` value. If the `output_field`
 is one that requires some sort of value conversion like `IntegerField`, it
 will raise a `ValueError`

 See repro repo:
 https://github.com/DanielSchaffer/django_json_null_expression_repro

-- 
Ticket URL: <https://code.djangoproject.com/ticket/34641>
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/01070188978daa90-015186fc-d097-4037-bb8c-7159f1dd2933-000000%40eu-central-1.amazonses.com.

Reply via email to