Add a new MySQL backend for safely working with BinaryFields.
Review Request #8636 — Created Jan. 19, 2017 and submitted
Django 1.6 introduced a BinaryField type for storing binary content. This is useful, except that, depending on database settings, MySQL will perform a UTF8 validation check on the binary content being saved to the database. This is clearly not what we want. Newer versions of Django (1.10.5+) fix this by declaring the content to be binary, using the "_binary" identifier when inserting/updating, but older versions are out of luck. This change introduces a new MySQL database backend that adds this support for older versions of Django. When activated (by setting the backend in settings.py), binary content will safely get the _binary prefix. This backend will also allow us to eventually tweak things in the database so that we can add better defaults (encodings and otherwise) for databases.
Switched Review Board to use this backend for MySQL. Verified that
I was able to import all the binary data that was in my old database
without getting an error (which I was receiving before).
- Change Summary:
-
Fixed a typo.
- Commit:
-
83e4701575ee86adf15b523e86cd9880667b01a21ad04a849cb28084d67cf9cc52148db7ee644259
-
Tool: Pyflakes Processed Files: djblets/db/backends/mysql/base.py Ignored Files: djblets/db/backends/__init__.py djblets/db/backends/mysql/__init__.py Tool: PEP8 Style Checker Processed Files: djblets/db/backends/mysql/base.py Ignored Files: djblets/db/backends/__init__.py djblets/db/backends/mysql/__init__.py