summaryrefslogtreecommitdiff
path: root/django/core
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2006-09-26 10:46:34 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2006-09-26 10:46:34 +0000
commit4e76727fec2fa898314b4525a39ce995692f2a78 (patch)
tree894bb1f7e0781307a6599f890c67650f9038edff /django/core
parent5371ee1743dcfc6322dafeb292618c0405c00510 (diff)
Fixed #2188 -- Raise an error when using long CharFields in combination with
older MySQL versions. Thanks, Fraser Nevett <mail@nevett.org> . git-svn-id: http://code.djangoproject.com/svn/django/trunk@3855 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/core')
-rw-r--r--django/core/management.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/django/core/management.py b/django/core/management.py
index bcfcd60617..4fa40b5807 100644
--- a/django/core/management.py
+++ b/django/core/management.py
@@ -820,7 +820,8 @@ def get_validation_errors(outfile, app=None):
validates all models of all installed apps. Writes errors, if any, to outfile.
Returns number of errors.
"""
- from django.db import models
+ from django.conf import settings
+ from django.db import models, connection
from django.db.models.loading import get_app_errors
from django.db.models.fields.related import RelatedObject
@@ -862,6 +863,12 @@ def get_validation_errors(outfile, app=None):
if f.db_index not in (None, True, False):
e.add(opts, '"%s": "db_index" should be either None, True or False.' % f.name)
+ # Check that maxlength <= 255 if using older MySQL versions.
+ if settings.DATABASE_ENGINE == 'mysql':
+ db_version = connection.get_server_version()
+ if db_version < (5, 0, 3) and isinstance(f, (models.CharField, models.CommaSeparatedIntegerField, models.SlugField)) and f.maxlength > 255:
+ e.add(opts, '"%s": %s cannot have a "maxlength" greater than 255 when you are using a version of MySQL prior to 5.0.3 (you are using %s).' % (f.name, f.__class__.__name__, '.'.join(str(n) for n in db_version[:3])))
+
# Check to see if the related field will clash with any
# existing fields, m2m fields, m2m related objects or related objects
if f.rel: