Skip to content

Commit 176f016

Browse files
committed
Fix conditional
1 parent d1eb737 commit 176f016

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

django_mongodb_backend/schema.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -427,9 +427,7 @@ def _create_collection(self, model):
427427
"""
428428

429429
db = self.get_database()
430-
if not hasattr(model, "encrypted"):
431-
db.create_collection(model._meta.db_table)
432-
else:
430+
if hasattr(model, "encrypted") and model.encrypted:
433431
client = self.connection.connection
434432
ce = get_client_encryption(
435433
client,
@@ -442,14 +440,19 @@ def _create_collection(self, model):
442440
self._get_encrypted_fields_map(model),
443441
settings.KMS_PROVIDER,
444442
)
443+
else:
444+
db.create_collection(model._meta.db_table)
445445

446446
def _get_encrypted_fields_map(self, model):
447447
conn = self.connection
448448
fields = model._meta.fields
449449
return {
450450
"fields": [
451451
{
452-
"path": field.db_column,
452+
# (Pdb) fields[2].db_column
453+
# (Pdb) fields[2].name
454+
# 'ssn'
455+
"path": field.name,
453456
"bsonType": field.db_type(conn),
454457
# Specify queries in the field definition as a list of query
455458
# types e.g. queries=["equality", "range"]

0 commit comments

Comments
 (0)