Skip to content

Commit 167b0b6

Browse files
committed
fix SchemaEditor.alter_db_table() crash when table name is unchanged
1 parent 9253a74 commit 167b0b6

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

django_mongodb/features.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,6 @@ class DatabaseFeatures(BaseDatabaseFeatures):
131131
"schema.tests.SchemaTests.test_composed_constraint_with_fk",
132132
"schema.tests.SchemaTests.test_remove_ignored_unique_constraint_not_create_fk_index",
133133
"schema.tests.SchemaTests.test_unique_constraint",
134-
# pymongo.errors.OperationFailure: Can't rename a collection to itself
135-
"migrations.test_operations.OperationTests.test_alter_model_table_noop",
136-
"migrations.test_operations.OperationTests.test_rename_model_no_relations_with_db_table_noop",
137-
"migrations.test_operations.OperationTests.test_rename_model_with_db_table_rename_m2m",
138134
# subclasses of BaseDatabaseIntrospection may require a get_constraints() method
139135
"migrations.test_operations.OperationTests.test_add_func_unique_constraint",
140136
"migrations.test_operations.OperationTests.test_remove_func_unique_constraint",

django_mongodb/schema.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,6 @@ def remove_constraint(self, model, constraint):
7575
pass
7676

7777
def alter_db_table(self, model, old_db_table, new_db_table):
78+
if old_db_table == new_db_table:
79+
return
7880
self.connection.database[old_db_table].rename(new_db_table)

0 commit comments

Comments
 (0)