diff options
| author | Simon Charette <charette.s@gmail.com> | 2024-02-03 01:10:41 -0500 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2024-02-04 09:31:06 +0100 |
| commit | fe1cb62f5c3f87fafc4a6b52fee2ccc6c80c41e2 (patch) | |
| tree | 42805b8fe83e29846aaf38ab3370e25d7eb4819c /tests/schema | |
| parent | dfc77637ea5c1aa81caa72b1cf900e6931d61b54 (diff) | |
Refs #35149 -- Made equivalent db_default alterations noops.
This allows for an easier transition of preserving the literal nature of
non-compilable db_default.
Diffstat (limited to 'tests/schema')
| -rw-r--r-- | tests/schema/tests.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/schema/tests.py b/tests/schema/tests.py index cde3d7f991..04ad299aa6 100644 --- a/tests/schema/tests.py +++ b/tests/schema/tests.py @@ -2316,6 +2316,23 @@ class SchemaTests(TransactionTestCase): columns = self.column_classes(Author) self.assertIn("(missing)", columns["description"][1].default) + @isolate_apps("schema") + def test_db_default_equivalent_sql_noop(self): + class Author(Model): + name = TextField(db_default=Value("foo")) + + class Meta: + app_label = "schema" + + with connection.schema_editor() as editor: + editor.create_model(Author) + + new_field = TextField(db_default="foo") + new_field.set_attributes_from_name("name") + new_field.model = Author + with connection.schema_editor() as editor, self.assertNumQueries(0): + editor.alter_field(Author, Author._meta.get_field("name"), new_field) + @skipUnlessDBFeature( "supports_column_check_constraints", "can_introspect_check_constraints" ) |
