app/django/db/backends/mysql/validation.py
author Pawel Solyga <Pawel.Solyga@gmail.com>
Sun, 16 Nov 2008 15:26:40 +0000
changeset 485 2865922ea06a
parent 323 ff1a9aa48cfd
permissions -rw-r--r--
Change id to account in base.html template (without this change we couldn't signout using top right links and also couldn't display currently logged in account information on the left side of links). This patch is related to commit in revision r1022. http://code.google.com/p/soc/source/detail?r=1022 Patch by: Pawel Solyga

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]])))