#29086: Add a warning when saving bytestrings to CharFields
-------------------------------------+-------------------------------------
     Reporter:  Collin Anderson      |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  2.0
  (models, ORM)                      |
     Severity:  Release blocker      |               Resolution:
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Adam):

 * status:  closed => new
 * resolution:  wontfix =>


Comment:

 I'd like to re-open this for discussion, if possible.

 Ideally, saving bytes to a CharField wouldn't give a warning. It would
 just trust that the developer knows what they're doing. Namely, that they
 took care of the decode step, and to just pass the bytes right onto the
 database.

 I have a situation here where I have a CharField, I have some byte data, I
 know it's encoded in the same manner as the destination varchar field in
 the database. All these things are known to me. And yet, Django attempts
 to coerce the byte value into a string (adding a "b" in front and wrapping
 the thing in quotes as it goes), just before it's converted ''back'' into
 bytes when its sent to the database. That doesn't really make sense.

 The best course of action here is to just trust the developer. If the
 CharField value is bytes, leave it be.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/29086#comment:12>
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/072.255221d17949ea440c75d2e3eb0e2d34%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to