﻿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
34641	"Null value referenced from a JSONField using an expression that defines an output_field returns the string ""null"" instead of a None value"	Daniel Schaffer	nobody	"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

"	Bug	closed	Uncategorized	3.2	Normal	invalid			Unreviewed	0	0	0	0	0	0
