From 8e1491f30b9ebd5e607dab6a72bc1b9b00e00bd9 Mon Sep 17 00:00:00 2001 From: Dillon Walls Date: Mon, 7 Oct 2024 13:50:12 +0000 Subject: [PATCH] fixup! fixup! fixup! fixup! fixup! fixup! fixup! add support for mongodb Client Side Field Level Encryption (CSFLE) --- ming/encryption.py | 10 +++++++++- ming/odm/property.py | 3 ++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ming/encryption.py b/ming/encryption.py index 990c8dc..ee1e0f9 100644 --- a/ming/encryption.py +++ b/ming/encryption.py @@ -3,9 +3,11 @@ from typing import TYPE_CHECKING, TypeVar, Generic from ming.utils import classproperty +import ming.schema if TYPE_CHECKING: import ming.datastore + from ming.metadata import Field class MingEncryptionError(Exception): @@ -140,7 +142,13 @@ def _field_names(cls) -> list[str]: from ming.declarative import Document from ming.odm.declarative import MappedClass if issubclass(cls, Document): - return list(cls.m.field_index.keys()) + fields: list[tuple[str, Field]] = list(cls.m.field_index.items()) + field_names = [] + for (k, v) in fields: + if v.type in (ming.schema.Deprecated,): + continue + field_names.append(k) + return field_names if issubclass(cls, MappedClass): return list(cls.query.mapper.property_index.keys()) raise NotImplementedError("Unexpected class type. You must implement `field_names` as a @classproperty in your mixin implementation.") diff --git a/ming/odm/property.py b/ming/odm/property.py index 8806642..941a186 100644 --- a/ming/odm/property.py +++ b/ming/odm/property.py @@ -58,7 +58,8 @@ def __init__(self, field_type, *args, **kwargs): @property def include_in_repr(self): - if isinstance(self.field.schema, (S.Binary, S.Deprecated)): return False + if isinstance(self.field.schema, (S.Binary, S.Deprecated)): + return False return True def repr(self, doc):