Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Corrected problem with MySQL checks handler and related fields.

  • Loading branch information...
commit 494b408041c59e9079e624040d48412559f241ae 1 parent 151dae2
@freakboy3742 freakboy3742 authored
Showing with 14 additions and 16 deletions.
  1. +14 −16 django/db/backends/mysql/validation.py
View
30 django/db/backends/mysql/validation.py
@@ -12,23 +12,21 @@ def check_field(self, field, **kwargs):
from django.db import connection
errors = super(DatabaseValidation, self).check_field(field, **kwargs)
- try:
+
+ # Ignore any related fields.
+ if getattr(field, 'rel', None) is None:
field_type = field.db_type(connection)
- except AttributeError:
- # If the field is a relative field and the target model is
- # missing, then field.rel.to is not a model and doesn't have
- # `_meta` attribute.
- field_type = ''
- if (field_type.startswith('varchar') and field.unique
- and (field.max_length is None or int(field.max_length) > 255)):
- errors.append(
- checks.Error(
- ('Under mysql backend, the field cannot have a "max_length" '
- 'greated than 255 when it is unique.'),
- hint=None,
- obj=field,
- id='E047',
+ if (field_type.startswith('varchar') # Look for CharFields...
+ and field.unique # ... that are unique
+ and (field.max_length is None or int(field.max_length) > 255)):
+ errors.append(
+ checks.Error(
+ ('Under mysql backend, the field cannot have a "max_length" '
+ 'greated than 255 when it is unique.'),
+ hint=None,
+ obj=field,
+ id='E047',
+ )
)
- )
return errors
Please sign in to comment.
Something went wrong with that request. Please try again.