Skip to content

Commit 8e53ed0

Browse files
committed
make SchemaEditor.create_model() raise DatabaseError if collection exists
1 parent 215ae30 commit 8e53ed0

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

django_mongodb/features.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -688,10 +688,6 @@ def django_test_expected_failures(self):
688688
"migrations.test_commands.MigrateTests.test_sqlmigrate_replaced_migration",
689689
"migrations.test_commands.MigrateTests.test_sqlmigrate_squashed_migration",
690690
},
691-
"SchemaEditor.create_model() must raise DatabaseError rather than "
692-
"pymongo.errors.CollectionInvalid: collection already exists": {
693-
"migrations.test_commands.MigrateTests.test_migrate_initial_false",
694-
},
695691
}
696692

697693
@cached_property

django_mongodb/schema.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
from django.db.backends.base.schema import BaseDatabaseSchemaEditor
22

3+
from .query import wrap_database_errors
4+
35

46
class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
7+
@wrap_database_errors
58
def create_model(self, model):
69
self.connection.database.create_collection(model._meta.db_table)
710
# Make implicit M2M tables.

0 commit comments

Comments
 (0)