#35149: JSONField db_default requires wrapping values in json.dumps()
-------------------------------------+-------------------------------------
Reporter: David Sanders | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 5.0
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: JSONField | Triage Stage: Accepted
db_default |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by David Sanders):
> I feel like implicit output_field assignment only makes sense in a
context where we offer no way for the user to set it such as when they
provide a non-expression themselves. In all other cases the user can
provide an explicit output_field so it feels like we'd be guessing for
them.
Yep agreed, so thinking more about this:
>when they provide a non-expression themselves.
This is handled when you wrap it with Value so all good β
> in all other cases
What made me wonder was this case `foo =
JSONField(db_default=Value({'foo': 'bar'}))` however if we setup the
warning one option may be to include warning about expressions that don't
resolve like this.
For complex expressions that don't resolve ideally an output_field should
be supplied. Implicit setting output_field isn't helpful here π
> That's a good one. I'd say we might want to consider a check in future
versions but not necessarily backport such check to 5.0 and have this work
included as part of this ticket?
Yup not as a backport π As per process will ask on forum before creating
a ticket.
> Were you interested in taking the work when you reported the issue
David?
Not especially π€·ββοΈ I feel like you've already authored a solution βΊοΈ
--
Ticket URL: <https://code.djangoproject.com/ticket/35149#comment:7>
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/0107018d58977c4b-4839b88a-2ae5-4c78-9204-fc1abd32b7a9-000000%40eu-central-1.amazonses.com.