#23536: BinaryField on mysql gets retrieved as 'str', not as 'bytes'
-------------------------------+-------------------------------
Reporter: fbrau | Owner: nobody
Type: Bug | Status: new
Component: Uncategorized | Version: 1.6
Severity: Normal | Keywords: mysql BinaryField
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+-------------------------------
I have a project that uses BinaryFields to pickle dynamic data.
Last week when migrating from sqlite to mysql
using MySQL-for-Python-3 the BinaryField now gets
retrieved as 'str'.
Reading the docs about BinaryField it says it is stored as 'bytes'.
I know mysql stores blobs
as text (right?) but in that case the problem is django's
documentation.
In this particular case:
the attribute mymodel.myblob looked like: b'dadadadaa'
but type(mymodel.myblob) said it was a 'str'
(I'm bit outdated about latest python changes in strings, bytes
and unicode)
Anyways I had to bypass this different behaviour to act just
like the embedded sqlite driver. My 'solution' is not nice:
* I had to reparse the string to make it a 'bytes':
>>> self._tags = eval('b"'+self.tags[2:-1]+'"')
* And add proxy points to get and set the blob
The code is located at:
[https://code.google.com/p/tidy-django-
models/source/diff?spec=svn2dd52f4b6600c58b9a970cdcebfaf0b725cd0961&r=2dd52f4b6600c58b9a970cdcebfaf0b725cd0961&format=side&path=/tdmodels/tagged.py]
--
Ticket URL: <https://code.djangoproject.com/ticket/23536>
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/048.d7edfdd5f5bcead7cee5ff129bd4e381%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.