summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpremanand lakshmanan <prem1pre@gmail.com>2016-07-17 15:56:12 -0600
committerTim Graham <timograham@gmail.com>2016-07-28 10:33:14 -0400
commit5da7e3f7fd24381195e557d807118130ddbc5152 (patch)
treef67085d2566c22de32424da990dabf598cabe4b9
parentcd2e4293cbf3416af6c478c5aaab711cae88892c (diff)
Fixed #26114 -- Fixed AlterModelTable.describe() if db_table is None.
-rw-r--r--django/db/migrations/operations/models.py5
-rw-r--r--tests/migrations/test_operations.py7
2 files changed, 11 insertions, 1 deletions
diff --git a/django/db/migrations/operations/models.py b/django/db/migrations/operations/models.py
index b929367bce..8f311b32ea 100644
--- a/django/db/migrations/operations/models.py
+++ b/django/db/migrations/operations/models.py
@@ -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:
diff --git a/tests/migrations/test_operations.py b/tests/migrations/test_operations.py
index 743bcd81a4..86e58cc3e6 100644
--- a/tests/migrations/test_operations.py
+++ b/tests/migrations/test_operations.py
@@ -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.