summaryrefslogtreecommitdiff
path: root/django/db/backends/mysql/operations.py
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2019-04-19 20:34:20 +0200
committerGitHub <noreply@github.com>2019-04-19 20:34:20 +0200
commita41b09266dcdd01036d59d76fe926fe0386aaade (patch)
tree773fe7b12ec7629774a8b459d1f2d8002fa02c83 /django/db/backends/mysql/operations.py
parent12b7956fc3735101fcad597047b80b57efb5048a (diff)
downloaddjango-a41b09266dcdd01036d59d76fe926fe0386aaade.tar.gz
Fixed #30380 -- Handled bytes in MySQL backend for PyMySQL support.
This commit partly reverts efd8a82e268a82b3ad0be77bd5b4548c30bcb4d7.
Diffstat (limited to 'django/db/backends/mysql/operations.py')
-rw-r--r--django/db/backends/mysql/operations.py7
1 files changed, 3 insertions, 4 deletions
diff --git a/django/db/backends/mysql/operations.py b/django/db/backends/mysql/operations.py
index da15e79ec2..a0d1095edd 100644
--- a/django/db/backends/mysql/operations.py
+++ b/django/db/backends/mysql/operations.py
@@ -4,6 +4,7 @@ from django.conf import settings
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 @@ class DatabaseOperations(BaseDatabaseOperations):
# 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.decode(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