1
0
mirror of https://github.com/django/django.git synced 2024-12-22 17:16:24 +00:00

Refs #32503 -- Added assertion for effective default value when altering TextField to non-nullable with default.

This commit is contained in:
Tobias Krönke 2023-12-14 10:14:11 +01:00 committed by Mariusz Felisiak
parent e72b2826ff
commit 4b7fe146cc

View File

@ -1078,11 +1078,14 @@ class SchemaTests(TransactionTestCase):
def test_alter_text_field_to_not_null_with_default_value(self):
with connection.schema_editor() as editor:
editor.create_model(Note)
note = Note.objects.create(address=None)
old_field = Note._meta.get_field("address")
new_field = TextField(blank=True, default="", null=False)
new_field.set_attributes_from_name("address")
with connection.schema_editor() as editor:
editor.alter_field(Note, old_field, new_field, strict=True)
note.refresh_from_db()
self.assertEqual(note.address, "")
@skipUnlessDBFeature("can_defer_constraint_checks", "can_rollback_ddl")
def test_alter_fk_checks_deferred_constraints(self):