summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2013-05-05 19:44:43 +0200
committerAymeric Augustin <aymeric.augustin@m4x.org>2013-05-10 10:23:15 +0200
commit6d3d6081e83295b4d0af8d4dbcf388bebc33ba41 (patch)
tree98604114589c2d6d18f3f9f9370ca1262c066372 /django
parentb5d6a5b21a2af4f0b4c3e8e3ca4b44e77812d996 (diff)
[1.5.x] Fixed #20025 -- Pointed to a MySQLdb fork for Python 3.
Made a few minor compatibility adjustments. Backport of e81e319f from master.
Diffstat (limited to 'django')
-rw-r--r--django/db/backends/mysql/base.py3
-rw-r--r--django/db/backends/mysql/validation.py3
2 files changed, 4 insertions, 2 deletions
diff --git a/django/db/backends/mysql/base.py b/django/db/backends/mysql/base.py
index 65db3b6acb..38cf7e4284 100644
--- a/django/db/backends/mysql/base.py
+++ b/django/db/backends/mysql/base.py
@@ -383,8 +383,9 @@ class DatabaseWrapper(BaseDatabaseWrapper):
kwargs = {
'conv': django_conversions,
'charset': 'utf8',
- 'use_unicode': True,
}
+ if not six.PY3:
+ kwargs['use_unicode'] = True
settings_dict = self.settings_dict
if settings_dict['USER']:
kwargs['user'] = settings_dict['USER']
diff --git a/django/db/backends/mysql/validation.py b/django/db/backends/mysql/validation.py
index de7474d1e5..2ce957cce7 100644
--- a/django/db/backends/mysql/validation.py
+++ b/django/db/backends/mysql/validation.py
@@ -10,6 +10,7 @@ class DatabaseValidation(BaseDatabaseValidation):
from django.db import models
varchar_fields = (models.CharField, models.CommaSeparatedIntegerField,
models.SlugField)
- if isinstance(f, varchar_fields) and f.max_length > 255 and f.unique:
+ if (isinstance(f, varchar_fields) and f.unique
+ and (f.max_length is None or int(f.max_length) > 255)):
msg = '"%(name)s": %(cls)s cannot have a "max_length" greater than 255 when using "unique=True".'
errors.add(opts, msg % {'name': f.name, 'cls': f.__class__.__name__})