@@ -474,7 +474,7 @@ def _create_collection(self, model):
474474 )
475475 encrypted_fields_map = getattr (auto_encryption_opts , "_encrypted_fields_map" , None )
476476 if not encrypted_fields_map :
477- encrypted_fields = self ._get_encrypted_fields (model , client , create_data_keys = True )
477+ encrypted_fields = self ._get_encrypted_fields (model , create_data_keys = True )
478478 else :
479479 # If the encrypted fields map is provided, get the encrypted fields for the
480480 # specific collection.
@@ -484,14 +484,15 @@ def _create_collection(self, model):
484484 db .create_collection (db_table )
485485
486486 def _get_encrypted_fields (
487- self , model , client , create_data_keys = False , key_alt_name = None , client_encryption = None
487+ self , model , create_data_keys = False , key_alt_name = None , client_encryption = None
488488 ):
489489 """
490490 Recursively collect encryption schema data for fields in a model.
491491
492492 key_alt_name is the base path for this level, typically model._meta.db_table
493493 """
494494 connection = self .connection
495+ client = connection .connection
495496 fields = model ._meta .fields
496497 key_alt_name = key_alt_name or model ._meta .db_table
497498
@@ -548,7 +549,6 @@ def _get_encrypted_fields(
548549 field_list .append (field_dict )
549550 embedded_result = self ._get_encrypted_fields (
550551 field .embedded_model ,
551- client ,
552552 create_data_keys = create_data_keys ,
553553 key_alt_name = new_path ,
554554 client_encryption = client_encryption ,
0 commit comments