Loading django/db/migrations/operations/models.py +2 −2 Original line number Diff line number Diff line Loading @@ -248,7 +248,7 @@ class AlterUniqueTogether(Operation): return name.lower() == self.name.lower() def describe(self): return "Alter %s for %s (%s constraint(s))" % (self.option_name, self.name, len(self.unique_together)) return "Alter %s for %s (%s constraint(s))" % (self.option_name, self.name, len(self.unique_together or '')) class AlterIndexTogether(Operation): Loading Loading @@ -288,7 +288,7 @@ class AlterIndexTogether(Operation): return name.lower() == self.name.lower() def describe(self): return "Alter %s for %s (%s constraint(s))" % (self.option_name, self.name, len(self.index_together)) return "Alter %s for %s (%s constraint(s))" % (self.option_name, self.name, len(self.index_together or '')) class AlterOrderWithRespectTo(Operation): Loading django/db/migrations/state.py +0 −2 Original line number Diff line number Diff line Loading @@ -272,8 +272,6 @@ class ModelState(object): # First, make a Meta object meta_contents = {'app_label': self.app_label, "apps": apps} meta_contents.update(self.options) if "unique_together" in meta_contents: meta_contents["unique_together"] = list(meta_contents["unique_together"]) meta = type(str("Meta"), tuple(), meta_contents) # Then, work out our bases try: Loading tests/migrations/test_operations.py +8 −0 Original line number Diff line number Diff line Loading @@ -899,6 +899,10 @@ class OperationTests(OperationTestBase): operation.state_forwards("test_alunto", new_state) self.assertEqual(len(new_state.models["test_alunto", "pony"].options.get("unique_together", set())), 1) def test_alter_unique_together_remove(self): operation = migrations.AlterUniqueTogether("Pony", None) self.assertEqual(operation.describe(), "Alter unique_together for Pony (0 constraint(s))") def test_alter_index_together(self): """ Tests the AlterIndexTogether operation. Loading @@ -922,6 +926,10 @@ class OperationTests(OperationTestBase): operation.database_backwards("test_alinto", editor, new_state, project_state) self.assertIndexNotExists("test_alinto_pony", ["pink", "weight"]) def test_alter_index_together_remove(self): operation = migrations.AlterIndexTogether("Pony", None) self.assertEqual(operation.describe(), "Alter index_together for Pony (0 constraint(s))") def test_alter_model_options(self): """ Tests the AlterModelOptions operation. Loading Loading
django/db/migrations/operations/models.py +2 −2 Original line number Diff line number Diff line Loading @@ -248,7 +248,7 @@ class AlterUniqueTogether(Operation): return name.lower() == self.name.lower() def describe(self): return "Alter %s for %s (%s constraint(s))" % (self.option_name, self.name, len(self.unique_together)) return "Alter %s for %s (%s constraint(s))" % (self.option_name, self.name, len(self.unique_together or '')) class AlterIndexTogether(Operation): Loading Loading @@ -288,7 +288,7 @@ class AlterIndexTogether(Operation): return name.lower() == self.name.lower() def describe(self): return "Alter %s for %s (%s constraint(s))" % (self.option_name, self.name, len(self.index_together)) return "Alter %s for %s (%s constraint(s))" % (self.option_name, self.name, len(self.index_together or '')) class AlterOrderWithRespectTo(Operation): Loading
django/db/migrations/state.py +0 −2 Original line number Diff line number Diff line Loading @@ -272,8 +272,6 @@ class ModelState(object): # First, make a Meta object meta_contents = {'app_label': self.app_label, "apps": apps} meta_contents.update(self.options) if "unique_together" in meta_contents: meta_contents["unique_together"] = list(meta_contents["unique_together"]) meta = type(str("Meta"), tuple(), meta_contents) # Then, work out our bases try: Loading
tests/migrations/test_operations.py +8 −0 Original line number Diff line number Diff line Loading @@ -899,6 +899,10 @@ class OperationTests(OperationTestBase): operation.state_forwards("test_alunto", new_state) self.assertEqual(len(new_state.models["test_alunto", "pony"].options.get("unique_together", set())), 1) def test_alter_unique_together_remove(self): operation = migrations.AlterUniqueTogether("Pony", None) self.assertEqual(operation.describe(), "Alter unique_together for Pony (0 constraint(s))") def test_alter_index_together(self): """ Tests the AlterIndexTogether operation. Loading @@ -922,6 +926,10 @@ class OperationTests(OperationTestBase): operation.database_backwards("test_alinto", editor, new_state, project_state) self.assertIndexNotExists("test_alinto_pony", ["pink", "weight"]) def test_alter_index_together_remove(self): operation = migrations.AlterIndexTogether("Pony", None) self.assertEqual(operation.describe(), "Alter index_together for Pony (0 constraint(s))") def test_alter_model_options(self): """ Tests the AlterModelOptions operation. Loading