summaryrefslogtreecommitdiff
path: root/django/db/backends/mysql/operations.py
diff options
context:
space:
mode:
authorJon Dufresne <jon.dufresne@gmail.com>2018-10-01 07:59:34 -0500
committerCarlton Gibson <carlton.gibson@noumenal.es>2018-10-03 10:37:36 +0200
commitefd8a82e268a82b3ad0be77bd5b4548c30bcb4d7 (patch)
tree9e5df1700682b4f86ca3d1b00855bf25c164e410 /django/db/backends/mysql/operations.py
parent3212008ba602668f7923852454b508a400dd732e (diff)
downloaddjango-efd8a82e268a82b3ad0be77bd5b4548c30bcb4d7.tar.gz
Refs #27795 -- Removed force_bytes() usage in MySQL backend.
The mysqlclient cursor attribute `_last_executed` is always stored as bytes. Decode it. TextField values are already type str. No need to decode.
Diffstat (limited to 'django/db/backends/mysql/operations.py')
-rw-r--r--django/db/backends/mysql/operations.py15
1 files changed, 5 insertions, 10 deletions
diff --git a/django/db/backends/mysql/operations.py b/django/db/backends/mysql/operations.py
index 8a43c907ac..973a5548ff 100644
--- a/django/db/backends/mysql/operations.py
+++ b/django/db/backends/mysql/operations.py
@@ -5,7 +5,6 @@ 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_text
class DatabaseOperations(BaseDatabaseOperations):
@@ -142,7 +141,10 @@ class DatabaseOperations(BaseDatabaseOperations):
# With MySQLdb, cursor objects have an (undocumented) "_last_executed"
# attribute where the exact query sent to the database is saved.
# See MySQLdb/cursors.py in the source distribution.
- return force_text(getattr(cursor, '_last_executed', None), errors='replace')
+ query = getattr(cursor, '_last_executed', None)
+ if query is not None:
+ query = query.decode(errors='replace')
+ return query
def no_limit_value(self):
# 2**64 - 1, as recommended by the MySQL documentation
@@ -233,9 +235,7 @@ class DatabaseOperations(BaseDatabaseOperations):
def get_db_converters(self, expression):
converters = super().get_db_converters(expression)
internal_type = expression.output_field.get_internal_type()
- if internal_type == 'TextField':
- converters.append(self.convert_textfield_value)
- elif internal_type in ['BooleanField', 'NullBooleanField']:
+ if internal_type in ['BooleanField', 'NullBooleanField']:
converters.append(self.convert_booleanfield_value)
elif internal_type == 'DateTimeField':
if settings.USE_TZ:
@@ -244,11 +244,6 @@ class DatabaseOperations(BaseDatabaseOperations):
converters.append(self.convert_uuidfield_value)
return converters
- def convert_textfield_value(self, value, expression, connection):
- if value is not None:
- value = force_text(value)
- return value
-
def convert_booleanfield_value(self, value, expression, connection):
if value in (0, 1):
value = bool(value)