Add a Django patch to work around a mysqlclient incompatibility.
Review Request #11898 — Created Jan. 2, 2022 and submitted — Latest diff uploaded
Django, up through 1.11, made an assumption that
mysqlclient
's
database connection class hadbytes
in a mapping of internal data type
converters. This assumption worked in Python 2.7, sincebytes
and
str
were the same thing, but it broke on Python 3. Themysqlclient
developers temporarily added compatibility for this, but have recently
removed that as ofmysqlclient 2.1
, since Django 2.0+ doesn't exhibit
this problem.This change adds a patch to work around that problem. It pre-populates
the neededbytes
mapping in the conversion map that Django sets up and
passes tomysqlclient
. Django's improper logic will still kick in, but
it will no longer fail on newer versions ofmysqlclient
without that
workaround.
Tested MySQL support on Python 3 on Django 1.6 through 2.0, with
mysqlclient
1.4.6, 2.0, and 2.1.