From 4b7fe146ccf6c3fa041f3b43099c93a68e78be96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Kr=C3=B6nke?= Date: Thu, 14 Dec 2023 10:14:11 +0100 Subject: [PATCH] Refs #32503 -- Added assertion for effective default value when altering TextField to non-nullable with default. --- tests/schema/tests.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/schema/tests.py b/tests/schema/tests.py index c4e61976f1..61244f75b4 100644 --- a/tests/schema/tests.py +++ b/tests/schema/tests.py @@ -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):