diff options
| author | Iuri de Silvio <iurisilvio@gmail.com> | 2022-08-24 10:10:56 -0300 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2022-08-26 06:14:44 +0200 |
| commit | 166a3b32632c141541d1c3f0eff18e1d8b389404 (patch) | |
| tree | 3a1af8e55f4a3f5cf052e982e8eca31d2360d906 /tests | |
| parent | 71902e0d9f93670c4f93ff9d66095b0e571be74b (diff) | |
Fixed #33953 -- Reverted "Fixed #33201 -- Made RenameModel operation a noop for models with db_table."
Regression in afeafd6036616bac8263d762c1610f22241c0187.
This reverts afeafd6036616bac8263d762c1610f22241c0187.
Thanks Timothy Thomas for the report.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/migrations/test_operations.py | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/tests/migrations/test_operations.py b/tests/migrations/test_operations.py index f2edf6ac73..c83e333136 100644 --- a/tests/migrations/test_operations.py +++ b/tests/migrations/test_operations.py @@ -1058,8 +1058,8 @@ class OperationTests(OperationTestBase): Pony._meta.get_field("riders").remote_field.through.objects.count(), 2 ) - def test_rename_model_with_db_table_noop(self): - app_label = "test_rmwdbtn" + def test_rename_model_with_db_table_rename_m2m(self): + app_label = "test_rmwdbrm2m" project_state = self.apply_operations( app_label, ProjectState(), @@ -1069,32 +1069,28 @@ class OperationTests(OperationTestBase): fields=[ ("id", models.AutoField(primary_key=True)), ], - options={"db_table": "rider"}, ), migrations.CreateModel( "Pony", fields=[ ("id", models.AutoField(primary_key=True)), - ( - "rider", - models.ForeignKey("%s.Rider" % app_label, models.CASCADE), - ), + ("riders", models.ManyToManyField("Rider")), ], + options={"db_table": "pony"}, ), ], ) new_state = project_state.clone() - operation = migrations.RenameModel("Rider", "Runner") + operation = migrations.RenameModel("Pony", "PinkPony") operation.state_forwards(app_label, new_state) - - with connection.schema_editor() as editor: - with self.assertNumQueries(0): - operation.database_forwards(app_label, editor, project_state, new_state) with connection.schema_editor() as editor: - with self.assertNumQueries(0): - operation.database_backwards( - app_label, editor, new_state, project_state - ) + operation.database_forwards(app_label, editor, project_state, new_state) + + Pony = new_state.apps.get_model(app_label, "PinkPony") + Rider = new_state.apps.get_model(app_label, "Rider") + pony = Pony.objects.create() + rider = Rider.objects.create() + pony.riders.add(rider) def test_rename_m2m_target_model(self): app_label = "test_rename_m2m_target_model" |
