Refs #25415 -- Made MySQL backend skip field validation of unsupported models.
This commit is contained in:
parent
00c7bfadf4
commit
391c450fba
@ -32,15 +32,23 @@ class DatabaseValidation(BaseDatabaseValidation):
|
|||||||
No character (varchar) fields can have a length exceeding 255
|
No character (varchar) fields can have a length exceeding 255
|
||||||
characters if they have a unique index on them.
|
characters if they have a unique index on them.
|
||||||
"""
|
"""
|
||||||
from django.db import connection
|
|
||||||
|
|
||||||
errors = super(DatabaseValidation, self).check_field(field, **kwargs)
|
errors = super(DatabaseValidation, self).check_field(field, **kwargs)
|
||||||
|
|
||||||
# Ignore any related fields.
|
# Ignore any related fields.
|
||||||
if getattr(field, 'remote_field', None) is None:
|
if getattr(field, 'remote_field', None):
|
||||||
field_type = field.db_type(connection)
|
return errors
|
||||||
|
|
||||||
# Ignore any non-concrete fields
|
# Ignore fields with unsupported features.
|
||||||
|
db_supports_all_required_features = all(
|
||||||
|
getattr(self.connection.features, feature, False)
|
||||||
|
for feature in field.model._meta.required_db_features
|
||||||
|
)
|
||||||
|
if not db_supports_all_required_features:
|
||||||
|
return errors
|
||||||
|
|
||||||
|
field_type = field.db_type(self.connection)
|
||||||
|
|
||||||
|
# Ignore non-concrete fields.
|
||||||
if field_type is None:
|
if field_type is None:
|
||||||
return errors
|
return errors
|
||||||
|
|
||||||
|
@ -217,7 +217,7 @@ class CharFieldTests(TestCase):
|
|||||||
field = models.CharField(unique=True, max_length=256)
|
field = models.CharField(unique=True, max_length=256)
|
||||||
|
|
||||||
field = Model._meta.get_field('field')
|
field = Model._meta.get_field('field')
|
||||||
validator = DatabaseValidation(connection=None)
|
validator = DatabaseValidation(connection=connection)
|
||||||
errors = validator.check_field(field)
|
errors = validator.check_field(field)
|
||||||
expected = [
|
expected = [
|
||||||
Error(
|
Error(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user