summaryrefslogtreecommitdiff
path: root/tests/schema
diff options
context:
space:
mode:
authorTobias Krönke <tobias.kroenke@truffls.com>2023-12-14 10:14:11 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2023-12-14 10:53:37 +0100
commit4b7fe146ccf6c3fa041f3b43099c93a68e78be96 (patch)
tree2cda6736c7c62f69b003cc30f5b367df7e1689f9 /tests/schema
parente72b2826ff1eaf2f48ee54a40d2f2988a1fdbb0a (diff)
Refs #32503 -- Added assertion for effective default value when altering TextField to non-nullable with default.
Diffstat (limited to 'tests/schema')
-rw-r--r--tests/schema/tests.py3
1 files changed, 3 insertions, 0 deletions
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):