Refs #23919 -- Removed a MySQLdb workaround (refs #6052) for Python 2.

This commit is contained in:
Tim Graham 2017-01-23 10:36:48 -05:00
parent a87d6b69a7
commit 5b95d421f7
1 changed files with 2 additions and 8 deletions

View File

@ -10,7 +10,6 @@ from django.db import utils
from django.db.backends import utils as backend_utils
from django.db.backends.base.base import BaseDatabaseWrapper
from django.utils.functional import cached_property
from django.utils.safestring import SafeBytes, SafeText
try:
import MySQLdb as Database
@ -43,9 +42,7 @@ if (version < (1, 2, 1) or (
# MySQLdb-1.2.1 returns TIME columns as timedelta -- they are more like
# timedelta in terms of actual behavior as they are signed and include days --
# and Django expects time, so we still need to override that. We also need to
# add special handling for SafeText and SafeBytes as MySQLdb's type
# checking is too tight to catch those (see Django ticket #6052).
# and Django expects time.
django_conversions = conversions.copy()
django_conversions.update({
FIELD_TYPE.TIME: backend_utils.typecast_time,
@ -249,10 +246,7 @@ class DatabaseWrapper(BaseDatabaseWrapper):
return kwargs
def get_new_connection(self, conn_params):
conn = Database.connect(**conn_params)
conn.encoders[SafeText] = conn.encoders[str]
conn.encoders[SafeBytes] = conn.encoders[bytes]
return conn
return Database.connect(**conn_params)
def init_connection_state(self):
assignments = []