summaryrefslogtreecommitdiff
path: root/tests/schema
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2021-09-01 13:26:46 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2021-09-01 20:54:12 +0200
commit338fc0e7f10f7ca781b059f2ff46e1a1a85c91f8 (patch)
treefbeb41ab0e5eeb54494e19c3528b9505f0caba88 /tests/schema
parentf65eb4664603fd66d638b78c670da12b00f6b907 (diff)
downloaddjango-338fc0e7f10f7ca781b059f2ff46e1a1a85c91f8.tar.gz
Fixed #33080 -- Preserved nullability of textual fields on Oracle.
Thanks Matt Hoskins for the report.
Diffstat (limited to 'tests/schema')
-rw-r--r--tests/schema/tests.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/schema/tests.py b/tests/schema/tests.py
index 7dfad1b5d6..9e23c4608e 100644
--- a/tests/schema/tests.py
+++ b/tests/schema/tests.py
@@ -863,6 +863,27 @@ class SchemaTests(TransactionTestCase):
with self.assertRaises(IntegrityError):
Note.objects.create(info=None)
+ @skipUnlessDBFeature('interprets_empty_strings_as_nulls')
+ def test_alter_textual_field_not_null_to_null(self):
+ """
+ Nullability for textual fields is preserved on databases that
+ interpret empty strings as NULLs.
+ """
+ with connection.schema_editor() as editor:
+ editor.create_model(Author)
+ columns = self.column_classes(Author)
+ # Field is nullable.
+ self.assertTrue(columns['uuid'][1][6])
+ # Change to NOT NULL.
+ old_field = Author._meta.get_field('uuid')
+ new_field = SlugField(null=False, blank=True)
+ new_field.set_attributes_from_name('uuid')
+ with connection.schema_editor() as editor:
+ editor.alter_field(Author, old_field, new_field, strict=True)
+ columns = self.column_classes(Author)
+ # Nullability is preserved.
+ self.assertTrue(columns['uuid'][1][6])
+
def test_alter_numeric_field_keep_null_status(self):
"""
Changing a field type shouldn't affect the not null status.