equal
deleted
inserted
replaced
9 characters in length. |
9 characters in length. |
10 - No character (varchar) fields can have a length exceeding 255 |
10 - No character (varchar) fields can have a length exceeding 255 |
11 characters if they have a unique index on them. |
11 characters if they have a unique index on them. |
12 """ |
12 """ |
13 from django.db import models |
13 from django.db import models |
14 from django.db import connection |
14 db_version = self.connection.get_server_version() |
15 db_version = connection.get_server_version() |
|
16 varchar_fields = (models.CharField, models.CommaSeparatedIntegerField, |
15 varchar_fields = (models.CharField, models.CommaSeparatedIntegerField, |
17 models.SlugField) |
16 models.SlugField) |
18 if isinstance(f, varchar_fields) and f.max_length > 255: |
17 if isinstance(f, varchar_fields) and f.max_length > 255: |
19 if db_version < (5, 0, 3): |
18 if db_version < (5, 0, 3): |
20 msg = '"%(name)s": %(cls)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 %(version)s).' |
19 msg = '"%(name)s": %(cls)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 %(version)s).' |
23 else: |
22 else: |
24 msg = None |
23 msg = None |
25 |
24 |
26 if msg: |
25 if msg: |
27 errors.add(opts, msg % {'name': f.name, 'cls': f.__class__.__name__, 'version': '.'.join([str(n) for n in db_version[:3]])}) |
26 errors.add(opts, msg % {'name': f.name, 'cls': f.__class__.__name__, 'version': '.'.join([str(n) for n in db_version[:3]])}) |
28 |
|