Skip to content

Commit 97a7d2a

Browse files
committed
Rename vars used for recursive calls
- parent_model -> path_prefix - new_parent_model -> path
1 parent a0a5a1a commit 97a7d2a

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

django_mongodb_backend/schema.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -489,20 +489,20 @@ def _create_collection(self, model):
489489
db.create_collection(db_table)
490490

491491
def _get_encrypted_fields(
492-
self, model, create_data_keys=False, key_alt_name=None, parent_model=None
492+
self, model, create_data_keys=False, key_alt_name=None, path_prefix=None
493493
):
494494
"""
495495
Recursively collect encryption schema data for only encrypted fields in a model.
496496
Returns None if no encrypted fields are found anywhere in the model hierarchy.
497497
498498
key_alt_name is the base path used for keyAltNames.
499-
parent_model is the dot-notated path inside the document for schema mapping.
499+
path_prefix is the dot-notated path inside the document for schema mapping.
500500
"""
501501
connection = self.connection
502502
client = connection.connection
503503
fields = model._meta.fields
504504
key_alt_name = key_alt_name or model._meta.db_table
505-
parent_model = parent_model or ""
505+
path_prefix = path_prefix or ""
506506

507507
options = client._options
508508
auto_encryption_opts = getattr(options, "auto_encryption_opts", None)
@@ -520,7 +520,7 @@ def _get_encrypted_fields(
520520

521521
for field in fields:
522522
new_key_alt_name = f"{key_alt_name}.{field.column}"
523-
new_parent_model = f"{parent_model}.{field.column}" if parent_model else field.column
523+
path = f"{path_prefix}.{field.column}" if path_prefix else field.column
524524

525525
# --- EmbeddedModelField ---
526526
if isinstance(field, EmbeddedModelField):
@@ -550,7 +550,7 @@ def _get_encrypted_fields(
550550

551551
field_dict = {
552552
"bsonType": "object",
553-
"path": new_parent_model,
553+
"path": path,
554554
"keyId": data_key,
555555
}
556556
if getattr(field, "queries", False):
@@ -563,7 +563,7 @@ def _get_encrypted_fields(
563563
field.embedded_model,
564564
create_data_keys=create_data_keys,
565565
key_alt_name=new_key_alt_name,
566-
parent_model=new_parent_model,
566+
path_prefix=path,
567567
)
568568
if embedded_result and embedded_result.get("fields"):
569569
field_list.extend(embedded_result["fields"])
@@ -595,7 +595,7 @@ def _get_encrypted_fields(
595595

596596
field_dict = {
597597
"bsonType": field.db_type(connection),
598-
"path": new_parent_model,
598+
"path": path,
599599
"keyId": data_key,
600600
}
601601
if getattr(field, "queries", False):

0 commit comments

Comments
 (0)