summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2021-03-29 10:10:19 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2021-03-30 11:42:15 +0200
commitf6018c1e63a04e0c12e2ca759e76e05ccf5e09de (patch)
treeb279fae73621a04e4447e311dbc61fa73efdfe04 /django
parent3c75f1f3cac7985e8a134fc1c33eb6e01639a04b (diff)
Fixed #32595 -- Fixed SchemaEditor.quote_value() crash with bytes.
Diffstat (limited to 'django')
-rw-r--r--django/db/backends/mysql/base.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/django/db/backends/mysql/base.py b/django/db/backends/mysql/base.py
index 470271c376..2c62182d31 100644
--- a/django/db/backends/mysql/base.py
+++ b/django/db/backends/mysql/base.py
@@ -230,7 +230,14 @@ class DatabaseWrapper(BaseDatabaseWrapper):
@async_unsafe
def get_new_connection(self, conn_params):
- return Database.connect(**conn_params)
+ connection = Database.connect(**conn_params)
+ # bytes encoder in mysqlclient doesn't work and was added only to
+ # prevent KeyErrors in Django < 2.0. We can remove this workaround when
+ # mysqlclient 2.1 becomes the minimal mysqlclient supported by Django.
+ # See https://github.com/PyMySQL/mysqlclient/issues/489
+ if connection.encoders.get(bytes) is bytes:
+ connection.encoders.pop(bytes)
+ return connection
def init_connection_state(self):
assignments = []