diff options
author | Claude Paroz <claude@2xlibre.net> | 2018-02-09 16:04:00 +0100 |
---|---|---|
committer | Tim Graham <timograham@gmail.com> | 2018-03-17 16:36:54 -0400 |
commit | 3c4ff2176323dd20507e35658599da220fbe1741 (patch) | |
tree | 7c03157fee56f9254aab476e90213ad337cb4c0e /django/db/backends/mysql/schema.py | |
parent | aa0ee372cd6644b687e37dd63d8df9cc75f6121e (diff) | |
download | django-3c4ff2176323dd20507e35658599da220fbe1741.tar.gz |
Fixed #29103 -- Removed bad 'b'-prefix added by MySQL's SchemaEditor.quote_value().
Diffstat (limited to 'django/db/backends/mysql/schema.py')
-rw-r--r-- | django/db/backends/mysql/schema.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/django/db/backends/mysql/schema.py b/django/db/backends/mysql/schema.py index 997fef1c0c..f969e6e4d8 100644 --- a/django/db/backends/mysql/schema.py +++ b/django/db/backends/mysql/schema.py @@ -25,9 +25,11 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor): sql_delete_pk = "ALTER TABLE %(table)s DROP PRIMARY KEY" def quote_value(self, value): - # Inner import to allow module to fail to load gracefully - import MySQLdb.converters - return MySQLdb.escape(value, MySQLdb.converters.conversions) + self.connection.ensure_connection() + quoted = self.connection.connection.escape(value, self.connection.connection.encoders) + if isinstance(value, str): + quoted = quoted.decode() + return quoted def _is_limited_data_type(self, field): db_type = field.db_type(self.connection) |