Skip to content

Commit 4da895c

Browse files
committed
Don't surpress encrypted error
1 parent 8e83ada commit 4da895c

File tree

1 file changed

+8
-15
lines changed

1 file changed

+8
-15
lines changed

django_mongodb_backend/schema.py

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
import contextlib
2-
31
from django.db.backends.base.schema import BaseDatabaseSchemaEditor
42
from django.db.models import Index, UniqueConstraint
5-
from pymongo.encryption import EncryptedCollectionError
63
from pymongo.operations import SearchIndexModel
74

85
from .encryption import get_encrypted_client
@@ -425,8 +422,8 @@ def _field_should_have_unique(self, field):
425422
def _create_collection(self, model):
426423
"""
427424
Create a collection or, if encryption is supported, create
428-
an encrypted connection then use it to create an encrypted
429-
client then use that to create an encrypted collection.
425+
an encrypted client then use that to create an encrypted
426+
collection.
430427
"""
431428

432429
if hasattr(model, "encrypted_fields_map"):
@@ -435,15 +432,11 @@ def _create_collection(self, model):
435432
)
436433
client = self.connection.connection
437434
encrypted_client = get_encrypted_client(auto_encryption_opts, client)
438-
439-
# If the collection exists, `create_encrypted_collection` will raise an
440-
# EncryptedCollectionError.
441-
with contextlib.suppress(EncryptedCollectionError):
442-
encrypted_client.create_encrypted_collection(
443-
client.database,
444-
model._meta.db_table,
445-
model.encrypted_fields_map,
446-
"local", # TODO: KMS provider should be configurable
447-
)
435+
encrypted_client.create_encrypted_collection(
436+
client.database,
437+
model._meta.db_table,
438+
model.encrypted_fields_map,
439+
"local", # TODO: KMS provider should be configurable
440+
)
448441
else:
449442
self.get_database().create_collection(model._meta.db_table)

0 commit comments

Comments
 (0)