mirror of
				https://github.com/django/django.git
				synced 2025-10-31 09:41:08 +00:00 
			
		
		
		
	[1.7.x] Fixed #22975: Don't call rename SQL if not needed
This commit is contained in:
		| @@ -769,6 +769,26 @@ class OperationTests(OperationTestBase): | ||||
|         self.assertTableExists("test_almota_pony") | ||||
|         self.assertTableNotExists("test_almota_pony_2") | ||||
|  | ||||
|     def test_alter_model_table_noop(self): | ||||
|         """ | ||||
|         Tests the AlterModelTable operation if the table name is not changed. | ||||
|         """ | ||||
|         project_state = self.set_up_test_model("test_almota") | ||||
|         # Test the state alteration | ||||
|         operation = migrations.AlterModelTable("Pony", "test_almota_pony") | ||||
|         new_state = project_state.clone() | ||||
|         operation.state_forwards("test_almota", new_state) | ||||
|         self.assertEqual(new_state.models["test_almota", "pony"].options["db_table"], "test_almota_pony") | ||||
|         # Test the database alteration | ||||
|         self.assertTableExists("test_almota_pony") | ||||
|         with connection.schema_editor() as editor: | ||||
|             operation.database_forwards("test_almota", editor, project_state, new_state) | ||||
|         self.assertTableExists("test_almota_pony") | ||||
|         # And test reversal | ||||
|         with connection.schema_editor() as editor: | ||||
|             operation.database_backwards("test_almota", editor, new_state, project_state) | ||||
|         self.assertTableExists("test_almota_pony") | ||||
|  | ||||
|     def test_alter_field(self): | ||||
|         """ | ||||
|         Tests the AlterField operation. | ||||
|   | ||||
		Reference in New Issue
	
	Block a user