Fixed #26114 -- Fixed AlterModelTable.describe() if db_table is None.
This commit is contained in:
parent
cd2e4293cb
commit
5da7e3f7fd
|
@ -465,7 +465,10 @@ class AlterModelTable(ModelOperation):
|
|||
return self.database_forwards(app_label, schema_editor, from_state, to_state)
|
||||
|
||||
def describe(self):
|
||||
return "Rename table for %s to %s" % (self.name, self.table)
|
||||
return "Rename table for %s to %s" % (
|
||||
self.name,
|
||||
self.table if self.table is not None else "(default)"
|
||||
)
|
||||
|
||||
def reduce(self, operation, in_between, app_label=None):
|
||||
if isinstance(operation, (AlterModelTable, DeleteModel)) and self.name_lower == operation.name_lower:
|
||||
|
|
|
@ -1154,6 +1154,13 @@ class OperationTests(OperationTestBase):
|
|||
self.assertEqual(definition[1], [])
|
||||
self.assertEqual(definition[2], {'name': "Pony", 'table': "test_almota_pony_2"})
|
||||
|
||||
def test_alter_model_table_none(self):
|
||||
"""
|
||||
Tests the AlterModelTable operation if the table name is set to None.
|
||||
"""
|
||||
operation = migrations.AlterModelTable("Pony", None)
|
||||
self.assertEqual(operation.describe(), "Rename table for Pony to (default)")
|
||||
|
||||
def test_alter_model_table_noop(self):
|
||||
"""
|
||||
Tests the AlterModelTable operation if the table name is not changed.
|
||||
|
|
Loading…
Reference in New Issue