mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
Fixed #33080 -- Preserved nullability of textual fields on Oracle.
Thanks Matt Hoskins for the report.
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user