@@ -489,20 +489,20 @@ def _create_collection(self, model):
489
489
db .create_collection (db_table )
490
490
491
491
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
493
493
):
494
494
"""
495
495
Recursively collect encryption schema data for only encrypted fields in a model.
496
496
Returns None if no encrypted fields are found anywhere in the model hierarchy.
497
497
498
498
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.
500
500
"""
501
501
connection = self .connection
502
502
client = connection .connection
503
503
fields = model ._meta .fields
504
504
key_alt_name = key_alt_name or model ._meta .db_table
505
- parent_model = parent_model or ""
505
+ path_prefix = path_prefix or ""
506
506
507
507
options = client ._options
508
508
auto_encryption_opts = getattr (options , "auto_encryption_opts" , None )
@@ -520,7 +520,7 @@ def _get_encrypted_fields(
520
520
521
521
for field in fields :
522
522
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
524
524
525
525
# --- EmbeddedModelField ---
526
526
if isinstance (field , EmbeddedModelField ):
@@ -550,7 +550,7 @@ def _get_encrypted_fields(
550
550
551
551
field_dict = {
552
552
"bsonType" : "object" ,
553
- "path" : new_parent_model ,
553
+ "path" : path ,
554
554
"keyId" : data_key ,
555
555
}
556
556
if getattr (field , "queries" , False ):
@@ -563,7 +563,7 @@ def _get_encrypted_fields(
563
563
field .embedded_model ,
564
564
create_data_keys = create_data_keys ,
565
565
key_alt_name = new_key_alt_name ,
566
- parent_model = new_parent_model ,
566
+ path_prefix = path ,
567
567
)
568
568
if embedded_result and embedded_result .get ("fields" ):
569
569
field_list .extend (embedded_result ["fields" ])
@@ -595,7 +595,7 @@ def _get_encrypted_fields(
595
595
596
596
field_dict = {
597
597
"bsonType" : field .db_type (connection ),
598
- "path" : new_parent_model ,
598
+ "path" : path ,
599
599
"keyId" : data_key ,
600
600
}
601
601
if getattr (field , "queries" , False ):
0 commit comments