diff --git a/mongo_connector/doc_managers/doc_manager_base.py b/mongo_connector/doc_managers/doc_manager_base.py index 2320b8f9..b7076008 100644 --- a/mongo_connector/doc_managers/doc_manager_base.py +++ b/mongo_connector/doc_managers/doc_manager_base.py @@ -84,9 +84,9 @@ def _unset_field(doc, to_unset): where[index_or_key] = None else: # Unset field removes it entirely. - del where[index_or_key] + where.pop(index_or_key, None) else: - del doc[to_unset] + doc.pop(to_unset, None) except (KeyError, IndexError, ValueError): source_version = get_mininum_mongodb_version() if source_version is None or source_version.at_least(2, 6):