mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +00:00
Refs #35149 -- Made equivalent db_default alterations noops.
This allows for an easier transition of preserving the literal nature of non-compilable db_default.
This commit is contained in:
parent
dfc77637ea
commit
fe1cb62f5c
2 changed files with 25 additions and 0 deletions
|
@ -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"
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue