Skip to content

Commit 945f7c8

Browse files
committed
fix SchemaEditor.alter_db_table() crash when table name is unchanged
1 parent 828634c commit 945f7c8

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
@@ -113,10 +113,6 @@ class DatabaseFeatures(BaseDatabaseFeatures):
113113
"schema.tests.SchemaTests.test_composed_constraint_with_fk",
114114
"schema.tests.SchemaTests.test_remove_ignored_unique_constraint_not_create_fk_index",
115115
"schema.tests.SchemaTests.test_unique_constraint",
116-
# pymongo.errors.OperationFailure: Can't rename a collection to itself
117-
"migrations.test_operations.OperationTests.test_alter_model_table_noop",
118-
"migrations.test_operations.OperationTests.test_rename_model_no_relations_with_db_table_noop",
119-
"migrations.test_operations.OperationTests.test_rename_model_with_db_table_rename_m2m",
120116
}
121117
# $bitAnd, #bitOr, and $bitXor are new in MongoDB 6.3.
122118
_django_test_expected_failures_bitwise = {

django_mongodb/schema.py

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

121121
def alter_db_table(self, model, old_db_table, new_db_table):
122+
if old_db_table == new_db_table:
123+
return
122124
self.connection.database[old_db_table].rename(new_db_table)

0 commit comments

Comments
 (0)