From 463952d94014ac2ea70a96828ddbf1330b504fc7 Mon Sep 17 00:00:00 2001 From: Sergey Fedoseev Date: Wed, 17 Sep 2014 11:34:10 +0600 Subject: Fixed #23503 -- Fixed renaming of model with self-referential m2m field. --- tests/migrations/test_operations.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'tests') diff --git a/tests/migrations/test_operations.py b/tests/migrations/test_operations.py index 82292ac69f..bddb09f9e7 100644 --- a/tests/migrations/test_operations.py +++ b/tests/migrations/test_operations.py @@ -472,6 +472,22 @@ class OperationTests(OperationTestBase): self.assertFKExists("test_rmwsrf_rider", ["friend_id"], ("test_rmwsrf_rider", "id")) self.assertFKNotExists("test_rmwsrf_rider", ["friend_id"], ("test_rmwsrf_horserider", "id")) + def test_rename_model_with_self_referential_m2m(self): + app_label = "test_rename_model_with_self_referential_m2m" + + project_state = self.apply_operations(app_label, ProjectState(), operations=[ + migrations.CreateModel("ReflexivePony", fields=[ + ("ponies", models.ManyToManyField("self")), + ]), + ]) + project_state = self.apply_operations(app_label, project_state, operations=[ + migrations.RenameModel("ReflexivePony", "ReflexivePony2"), + ]) + apps = project_state.render() + Pony = apps.get_model(app_label, "ReflexivePony2") + pony = Pony.objects.create() + pony.ponies.add(pony) + def test_add_field(self): """ Tests the AddField operation. -- cgit v1.3