Skip to content

Commit 0d6b93d

Browse files
timgrahamWaVEV
authored andcommitted
fix SchemaEditor.alter_db_table() crash when table name is unchanged
1 parent a16b29f commit 0d6b93d

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
@@ -132,10 +132,6 @@ class DatabaseFeatures(BaseDatabaseFeatures):
132132
"schema.tests.SchemaTests.test_composed_constraint_with_fk",
133133
"schema.tests.SchemaTests.test_remove_ignored_unique_constraint_not_create_fk_index",
134134
"schema.tests.SchemaTests.test_unique_constraint",
135-
# pymongo.errors.OperationFailure: Can't rename a collection to itself
136-
"migrations.test_operations.OperationTests.test_alter_model_table_noop",
137-
"migrations.test_operations.OperationTests.test_rename_model_no_relations_with_db_table_noop",
138-
"migrations.test_operations.OperationTests.test_rename_model_with_db_table_rename_m2m",
139135
# subclasses of BaseDatabaseIntrospection may require a get_constraints() method
140136
"migrations.test_operations.OperationTests.test_add_func_unique_constraint",
141137
"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)