| 1 | diff --git a/django/db/backends/mysql/base.py b/django/db/backends/mysql/base.py
|
|---|
| 2 | --- a/django/db/backends/mysql/base.py
|
|---|
| 3 | +++ b/django/db/backends/mysql/base.py
|
|---|
| 4 | @@ -239,6 +239,14 @@
|
|---|
| 5 | self.connection = None
|
|---|
| 6 | return False
|
|---|
| 7 |
|
|---|
| 8 | + def _connect(self, **kwargs):
|
|---|
| 9 | + from django.utils.safestring import SafeString, SafeUnicode
|
|---|
| 10 | + from types import StringType, UnicodeType
|
|---|
| 11 | + connection = Database.connect(**kwargs)
|
|---|
| 12 | + connection.encoders[SafeString] = connection.encoders[StringType]
|
|---|
| 13 | + connection.encoders[SafeUnicode] = connection.encoders[UnicodeType]
|
|---|
| 14 | + return connection
|
|---|
| 15 | +
|
|---|
| 16 | def _cursor(self, settings):
|
|---|
| 17 | if not self._valid_connection():
|
|---|
| 18 | kwargs = {
|
|---|
| 19 | @@ -259,7 +267,7 @@
|
|---|
| 20 | if settings.DATABASE_PORT:
|
|---|
| 21 | kwargs['port'] = int(settings.DATABASE_PORT)
|
|---|
| 22 | kwargs.update(self.options)
|
|---|
| 23 | - self.connection = Database.connect(**kwargs)
|
|---|
| 24 | + self.connection = self._connect(**kwargs)
|
|---|
| 25 | cursor = CursorWrapper(self.connection.cursor())
|
|---|
| 26 | return cursor
|
|---|
| 27 |
|
|---|