Skip to content

Commit

Permalink
Fixed #20974 -- Added test for Mysql specific validation.
Browse files Browse the repository at this point in the history
  • Loading branch information
coder9042 committed Mar 4, 2014
1 parent 20da67d commit 703b07c
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/backends/tests.py
Expand Up @@ -153,6 +153,31 @@ def test_autoincrement(self):
else:
self.assertFalse(found_reset)

@unittest.skipUnless(connection.vendor == 'mysql',
"Test valid only for MySQL")
def test_mysql_specific_validation(self):
from django.db import models
from django.core.checks import Error
"""
Test that no character (varchar) fields can have a length
exceeding 255 characters if they have a unique index on them.
"""
class ModelForMysqlValidation(models.Model):
field1 = models.CharField(unique=True, max_length=256)

field = ModelForMysqlValidation._meta.get_field('field1')
errors = ModelForMysqlValidation.check()
expected = [
Error(
'MySQL does not allow unique CharFields to have a max_length > 255.',
hint=None,
obj=field,
id='mysql.E001',
)
]

self.assertEqual(errors, expected)


class DateQuotingTest(TestCase):

Expand Down

0 comments on commit 703b07c

Please sign in to comment.