diff options
| author | Marc Tamlyn <marc.tamlyn@gmail.com> | 2014-09-04 16:32:51 +0100 |
|---|---|---|
| committer | Marc Tamlyn <marc.tamlyn@gmail.com> | 2014-09-06 19:02:28 +0100 |
| commit | 48e10710074a06584b6f8331a6e74492be5acf18 (patch) | |
| tree | 8129da9afe985d3a688f605a38394e289f249405 /tests/commands_sql | |
| parent | f8fdb7177b79b79968a3f40612d33c7367ae584f (diff) | |
[1.7.x] Fixed #23416 -- Make sure DatabaseCreation respects checks.
Migrations respected Field.db_parameters()['check'], but
DatabaseCreation was still using just Field.db_type().
Backport of 14c8456 from master
Diffstat (limited to 'tests/commands_sql')
| -rw-r--r-- | tests/commands_sql/models.py | 1 | ||||
| -rw-r--r-- | tests/commands_sql/tests.py | 13 |
2 files changed, 14 insertions, 0 deletions
diff --git a/tests/commands_sql/models.py b/tests/commands_sql/models.py index 78ad722307..fe5768b3dd 100644 --- a/tests/commands_sql/models.py +++ b/tests/commands_sql/models.py @@ -8,3 +8,4 @@ class Comment(models.Model): class Book(models.Model): title = models.CharField(max_length=100, db_index=True) comments = models.ManyToManyField(Comment) + counter = models.PositiveIntegerField() diff --git a/tests/commands_sql/tests.py b/tests/commands_sql/tests.py index 3d9e234ff0..ef21acaca0 100644 --- a/tests/commands_sql/tests.py +++ b/tests/commands_sql/tests.py @@ -1,6 +1,7 @@ from __future__ import unicode_literals import re +import unittest from django.apps import apps from django.core.management.color import no_style @@ -43,6 +44,18 @@ class SQLCommandsTestCase(TestCase): 'commands_sql_comment', 'commands_sql_book', 'commands_sql_book_comments' }) + @unittest.skipUnless('PositiveIntegerField' in connections[DEFAULT_DB_ALIAS].creation.data_type_check_constraints, 'Backend does not have checks.') + def test_sql_create_check(self): + """Regression test for #23416 -- Check that db_params['check'] is respected.""" + app_config = apps.get_app_config('commands_sql') + output = sql_create(app_config, no_style(), connections[DEFAULT_DB_ALIAS]) + success = False + for statement in output: + if 'CHECK' in statement: + success = True + if not success: + self.fail("'CHECK' not found in ouput %s" % output) + def test_sql_delete(self): app_config = apps.get_app_config('commands_sql') output = sql_delete(app_config, no_style(), connections[DEFAULT_DB_ALIAS], close_connection=False) |
