summaryrefslogtreecommitdiff
path: root/django/db/backends/mysql/validation.py
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2008-08-11 12:11:25 +0000
committerRussell Keith-Magee <russell@keith-magee.com>2008-08-11 12:11:25 +0000
commit9dc4ba875f21d5690f6ad5995123a67a3c44bafe (patch)
tree621f876758ac16dceee95faf51973d4b05f1c830 /django/db/backends/mysql/validation.py
parentcec69eb70d1e2f84dc5a7fb172da88a79b0f5063 (diff)
downloaddjango-9dc4ba875f21d5690f6ad5995123a67a3c44bafe.tar.gz
Fixed #5461 -- Refactored the database backend code to use classes for the creation and introspection modules. Introduces a new validation module for DB-specific validation. This is a backwards incompatible change; see the wiki for details.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@8296 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/db/backends/mysql/validation.py')
-rw-r--r--django/db/backends/mysql/validation.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/django/db/backends/mysql/validation.py b/django/db/backends/mysql/validation.py
new file mode 100644
index 0000000000..85354a8468
--- /dev/null
+++ b/django/db/backends/mysql/validation.py
@@ -0,0 +1,13 @@
+from django.db.backends import BaseDatabaseValidation
+
+class DatabaseValidation(BaseDatabaseValidation):
+ def validate_field(self, errors, opts, f):
+ "Prior to MySQL 5.0.3, character fields could not exceed 255 characters"
+ from django.db import models
+ from django.db import connection
+ db_version = connection.get_server_version()
+ if db_version < (5, 0, 3) and isinstance(f, (models.CharField, models.CommaSeparatedIntegerField, models.SlugField)) and f.max_length > 255:
+ errors.add(opts,
+ '"%s": %s cannot have a "max_length" 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]])))
+ \ No newline at end of file