Skip to content

Commit

Permalink
fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! add support f…
Browse files Browse the repository at this point in the history
…or mongodb Client Side Field Level Encryption (CSFLE)
  • Loading branch information
dill0wn committed Oct 7, 2024
1 parent 8e1491f commit 04a0b77
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 8 additions & 1 deletion ming/encryption.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
if TYPE_CHECKING:
import ming.datastore
from ming.metadata import Field
from ming.odm.property import FieldProperty

Check warning on line 11 in ming/encryption.py

View check run for this annotation

Codecov / codecov/patch

ming/encryption.py#L9-L11

Added lines #L9 - L11 were not covered by tests


class MingEncryptionError(Exception):
Expand Down Expand Up @@ -150,7 +151,13 @@ def _field_names(cls) -> list[str]:
field_names.append(k)
return field_names
if issubclass(cls, MappedClass):
return list(cls.query.mapper.property_index.keys())
fields: list[tuple[str, FieldProperty]] = list(cls.query.mapper.property_index.items())
field_names = []
for (k, v) in fields:
if v.field.type in (ming.schema.Deprecated,):
continue
field_names.append(k)
return field_names
raise NotImplementedError("Unexpected class type. You must implement `field_names` as a @classproperty in your mixin implementation.")

Check warning on line 161 in ming/encryption.py

View check run for this annotation

Codecov / codecov/patch

ming/encryption.py#L161

Added line #L161 was not covered by tests

@classmethod
Expand Down
2 changes: 2 additions & 0 deletions ming/tests/test_encryption.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ class __mongometa__:
name = DecryptedField(str, 'name_encrypted')
name_encrypted = Field(S.Binary)
other = Field(str)
deprecated = FieldProperty(S.Deprecated)

doc = TestDoc.make_encr(dict(_id=1, name='Jerome', other='foo'))
doc.m.save()
Expand Down Expand Up @@ -303,6 +304,7 @@ class __mongometa__:
name = DecryptedProperty(str, 'name_encrypted')
name_encrypted = FieldProperty(S.Binary)
other = FieldProperty(str)
deprecated = FieldProperty(S.Deprecated)

u = TestMapped(_id=None, name="Jerome", other='foo')
self.session.flush()
Expand Down

0 comments on commit 04a0b77

Please sign in to comment.