diff --git a/django/__init__.py b/django/__init__.py index ba72922c740b..3fadcb44af81 100644 --- a/django/__init__.py +++ b/django/__init__.py @@ -1,6 +1,6 @@ from django.utils.version import get_version -VERSION = (2, 2, 29, 'alpha', 0) +VERSION = (2, 2, 30, 'alpha', 0) __version__ = get_version(VERSION) diff --git a/django/db/backends/mysql/base.py b/django/db/backends/mysql/base.py index 3764c9f4a027..526132c0beed 100644 --- a/django/db/backends/mysql/base.py +++ b/django/db/backends/mysql/base.py @@ -32,8 +32,8 @@ from .validation import DatabaseValidation # isort:skip version = Database.version_info -if version < (1, 3, 13): - raise ImproperlyConfigured('mysqlclient 1.3.13 or newer is required; you have %s.' % Database.__version__) +# if version < (1, 3, 13): +# raise ImproperlyConfigured('mysqlclient 1.3.13 or newer is required; you have %s.' % Database.__version__) # MySQLdb returns TIME columns as timedelta -- they are more like timedelta in diff --git a/django/db/backends/mysql/operations.py b/django/db/backends/mysql/operations.py index 250a004e0531..adce7ac3aea8 100644 --- a/django/db/backends/mysql/operations.py +++ b/django/db/backends/mysql/operations.py @@ -4,6 +4,7 @@ from django.db.backends.base.operations import BaseDatabaseOperations from django.utils import timezone from django.utils.duration import duration_microseconds +from django.utils.encoding import force_str class DatabaseOperations(BaseDatabaseOperations): @@ -141,10 +142,8 @@ def last_executed_query(self, cursor, sql, params): # With MySQLdb, cursor objects have an (undocumented) "_executed" # attribute where the exact query sent to the database is saved. # See MySQLdb/cursors.py in the source distribution. - query = getattr(cursor, '_executed', None) - if query is not None: - query = query.encode(errors='replace') - return query + # MySQLdb returns string, PyMySQL bytes. + return force_str(getattr(cursor, '_last_executed', None), errors='replace') def no_limit_value(self): # 2**64 - 1, as recommended by the MySQL documentation diff --git a/django/db/backends/mysql/schema.py b/django/db/backends/mysql/schema.py index 65d1f2442932..a4d339d73a7d 100644 --- a/django/db/backends/mysql/schema.py +++ b/django/db/backends/mysql/schema.py @@ -28,8 +28,9 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor): def quote_value(self, value): self.connection.ensure_connection() + # MySQLdb escapes to string, PyMySQL to bytes. quoted = self.connection.connection.escape(value, self.connection.connection.encoders) - if isinstance(value, str): + if isinstance(value, str) and isinstance(quoted, bytes): quoted = quoted.decode() return quoted