mirror of
https://github.com/django/django.git
synced 2025-08-03 18:38:50 +00:00
Fixed #34946 -- Preserved db_default on combined default field addition.
Regression in 7414704e88
.
This commit is contained in:
parent
656192c2c9
commit
8a28e983df
3 changed files with 29 additions and 5 deletions
|
@ -2257,6 +2257,23 @@ class SchemaTests(TransactionTestCase):
|
|||
columns = self.column_classes(AuthorDbDefault)
|
||||
self.assertEqual(columns["renamed_year"][1].default, "1985")
|
||||
|
||||
@isolate_apps("schema")
|
||||
def test_add_field_both_defaults_preserves_db_default(self):
|
||||
class Author(Model):
|
||||
class Meta:
|
||||
app_label = "schema"
|
||||
|
||||
with connection.schema_editor() as editor:
|
||||
editor.create_model(Author)
|
||||
|
||||
field = IntegerField(default=1985, db_default=1988)
|
||||
field.set_attributes_from_name("birth_year")
|
||||
field.model = Author
|
||||
with connection.schema_editor() as editor:
|
||||
editor.add_field(Author, field)
|
||||
columns = self.column_classes(Author)
|
||||
self.assertEqual(columns["birth_year"][1].default, "1988")
|
||||
|
||||
@skipUnlessDBFeature(
|
||||
"supports_column_check_constraints", "can_introspect_check_constraints"
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue