diff options
| author | Simon Charette <charette.s@gmail.com> | 2016-09-08 00:57:04 -0400 |
|---|---|---|
| committer | Simon Charette <charette.s@gmail.com> | 2016-09-09 00:48:50 -0400 |
| commit | aca939b6e545debd64c6464976abac8fd716b589 (patch) | |
| tree | d92483947688cd0febd3638f52f22843c41808f3 /tests | |
| parent | 331ca5391eb64cbac3a001209257beb93522d587 (diff) | |
Fixed #27195 -- Stopped dropping default when adding a nullable column.
Thanks Rob Golding from Zapier for the report.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/schema/tests.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/tests/schema/tests.py b/tests/schema/tests.py index 5baba26e00..ef4d36a0df 100644 --- a/tests/schema/tests.py +++ b/tests/schema/tests.py @@ -21,6 +21,7 @@ from django.db.transaction import atomic from django.test import ( TransactionTestCase, mock, skipIfDBFeature, skipUnlessDBFeature, ) +from django.test.utils import CaptureQueriesContext from django.utils.timezone import UTC from .fields import ( @@ -347,8 +348,12 @@ class SchemaTests(TransactionTestCase): # Add the new field new_field = IntegerField(null=True) new_field.set_attributes_from_name("age") - with connection.schema_editor() as editor: + with CaptureQueriesContext(connection) as ctx, connection.schema_editor() as editor: editor.add_field(Author, new_field) + drop_default_sql = editor.sql_alter_column_no_default % { + 'column': editor.quote_name(new_field.name), + } + self.assertFalse(any(drop_default_sql in query['sql'] for query in ctx.captured_queries)) # Ensure the field is right afterwards columns = self.column_classes(Author) self.assertEqual(columns['age'][0], "IntegerField") |
