Skip to content

Commit 527a517

Browse files
committed
Bug fix
If the encrypted_fields_map is provided, get the map for the specific collection.
1 parent 901db6f commit 527a517

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

django_mongodb_backend/schema.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,10 @@ def _create_collection(self, model):
446446
encrypted_fields_map = self._get_encrypted_fields_map(
447447
model, client, auto_encryption_opts
448448
)
449+
else:
450+
# If the encrypted fields map is provided, get the map for the
451+
# specific collection.
452+
encrypted_fields_map = encrypted_fields_map.get(db_table, None)
449453
db.create_collection(db_table, encryptedFields=encrypted_fields_map)
450454
else:
451455
db.create_collection(db_table)
@@ -461,7 +465,6 @@ def _get_encrypted_fields_map(self, model, client, auto_encryption_opts, from_db
461465
client,
462466
client.codec_options,
463467
)
464-
# Parse key vault namespace
465468
key_vault_db, key_vault_coll = auto_encryption_opts._key_vault_namespace.split(".", 1)
466469
key_vault_collection = client[key_vault_db][key_vault_coll]
467470
db_table = model._meta.db_table

0 commit comments

Comments
 (0)