#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

 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

 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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 

Reply via email to