Changeset 3872
- Timestamp:
- 09/26/06 21:42:31 (2 years ago)
- Files:
-
- django/trunk/AUTHORS (modified) (1 diff)
- django/trunk/django/core/management.py (modified) (2 diffs)
- django/trunk/django/db/backends/mysql/base.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/AUTHORS
r3867 r3872 120 120 Robin Munn <http://www.geekforgod.com/> 121 121 Nebojša Dorđević 122 Fraser Nevett <mail@nevett.org> 122 123 Sam Newman <http://www.magpiebrain.com/> 123 124 Neal Norwitz <nnorwitz@google.com> django/trunk/django/core/management.py
r3867 r3872 821 821 Returns number of errors. 822 822 """ 823 from django.db import models 823 from django.conf import settings 824 from django.db import models, connection 824 825 from django.db.models.loading import get_app_errors 825 826 from django.db.models.fields.related import RelatedObject … … 862 863 if f.db_index not in (None, True, False): 863 864 e.add(opts, '"%s": "db_index" should be either None, True or False.' % f.name) 865 866 # Check that maxlength <= 255 if using older MySQL versions. 867 if settings.DATABASE_ENGINE == 'mysql': 868 db_version = connection.get_server_version() 869 if db_version < (5, 0, 3) and isinstance(f, (models.CharField, models.CommaSeparatedIntegerField, models.SlugField)) and f.maxlength > 255: 870 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]))) 864 871 865 872 # Check to see if the related field will clash with any django/trunk/django/db/backends/mysql/base.py
r3868 r3872 14 14 from MySQLdb.constants import FIELD_TYPE 15 15 import types 16 import re 16 17 17 18 DatabaseError = Database.DatabaseError … … 24 25 FIELD_TYPE.TIME: util.typecast_time, 25 26 }) 27 28 # This should match the numerical portion of the version numbers (we can treat 29 # versions like 5.0.24 and 5.0.24a as the same). Based on the list of version 30 # at http://dev.mysql.com/doc/refman/4.1/en/news.html and 31 # http://dev.mysql.com/doc/refman/5.0/en/news.html . 32 server_version_re = re.compile(r'(\d{1,2})\.(\d{1,2})\.(\d{1,2})') 26 33 27 34 # This is an extra debug layer over MySQL queries, to display warnings. … … 62 69 self.connection = None 63 70 self.queries = [] 71 self.server_version = None 64 72 65 73 def _valid_connection(self): … … 110 118 self.connection.close() 111 119 self.connection = None 120 121 def get_server_version(self): 122 if not self.server_version: 123 if not self._valid_connection(): 124 self.cursor() 125 m = server_version_re.match(self.connection.get_server_info()) 126 if not m: 127 raise Exception('Unable to determine MySQL version from version string %r' % self.connection.get_server_info()) 128 self.server_version = m.groups() 129 return self.server_version 112 130 113 131 supports_constraints = True
