#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: closed
Component: Uncategorized | Version: 3.2
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------
Comment (by Daniel Schaffer):
Replying to [comment:1 Simon Charette]:
> Setting `Case(output_field)` doesn't issue a `CAST`.
>
> [https://docs.djangoproject.com/en/4.2/ref/models/database-
functions/#cast Using a proper] `Cast` should address your issue.
That's a better workaround, but it's still a workaround isn't it? I'd
argue this is a bug for two reasons:
- I wouldn't ever expect an ORM to implicitly convert a null value to the
string `"null"`
- it works differently depending on what the JSON structure looks like: if
the key doesn't exist at all, everything works as expected, but it breaks
if there's an actual defined value of `null`
--
Ticket URL: <https://code.djangoproject.com/ticket/34641#comment:2>
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/010701889b16c4dd-92d0bb34-d724-4012-9d7c-57adb4b1402a-000000%40eu-central-1.amazonses.com.