-
-
Notifications
You must be signed in to change notification settings - Fork 514
[Encryption] Fix BSON types and query option name #2785
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Encryption] Fix BSON types and query option name #2785
Conversation
@@ -2005,43 +1999,43 @@ parameters: | |||
path: tests/Doctrine/ODM/MongoDB/Tests/Tools/EncryptedFieldsMapGeneratorTest.php | |||
|
|||
- | |||
message: '#^Method Doctrine\\Persistence\\Mapping\\AbstractClassMetadataFactory@anonymous/tests/Doctrine/ODM/MongoDB/Tests/Tools/EncryptedFieldsMapGeneratorTest\.php\:165\:\:__construct\(\) has parameter \$classNames with no value type specified in iterable type array\.$#' | |||
message: '#^Method Doctrine\\Persistence\\Mapping\\AbstractClassMetadataFactory@anonymous/tests/Doctrine/ODM/MongoDB/Tests/Tools/EncryptedFieldsMapGeneratorTest\.php\:168\:\:__construct\(\) has parameter \$classNames with no value type specified in iterable type array\.$#' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The anonymous class name contains the line number it's defined. Each time the previous test is updated, this baseline entries need to be updated.
lib/Doctrine/ODM/MongoDB/Utility/EncryptedFieldsMapGenerator.php
Outdated
Show resolved
Hide resolved
}, | ||
// @todo allow setting a keyId in #[Encrypt] attribute |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@todo
removed, we don't need to support custom keyId
with queryable encryption auto-encryption. They are generated automatically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. We can create a separate ticket for the ODM type => BSON type mapping and handle that later, as it's not strictly necessary.
Type::TIMESTAMP => 'timestamp', | ||
Type::OBJECTID => 'objectId', | ||
Type::STRING => 'string', | ||
Type::BINDATA, Type::BINDATABYTEARRAY, Type::BINDATAFUNC, Type::BINDATACUSTOM, Type::BINDATAUUID, Type::BINDATAMD5, Type::BINDATAUUIDRFC4122 => 'binData', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to add a getBSONType
method to the Type
class and override it in the individual types? Happy to defer this work until later, but I think it may be more efficient especially if people use custom types that map to a given BSON type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking to add a bsonType
parameter to the #[Encrypt]
attribute, for custom needs. Adding Type::getBSONType()
is a better option. PHPORM-358
Type::OBJECTID => 'objectId', | ||
Type::STRING => 'string', | ||
Type::BINDATA, Type::BINDATABYTEARRAY, Type::BINDATAFUNC, Type::BINDATACUSTOM, Type::BINDATAUUID, Type::BINDATAMD5, Type::BINDATAUUIDRFC4122 => 'binData', | ||
// Type BOOL is not supported in encrypted fields map |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that limitation called out in the server docs somewhere? We should definitely call it out in our documentation so people can adapt their schema accordingly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested again, bool seems to be supported. I don't know why it was failing previously.
b7cb9de
into
doctrine:feature/queryable-encryption
Part of #2779
The Doctrine ODM type names doesn't match the BSON type names. We have to map them to create the
encryptedFieldsMap
.Also fix the name of the property
precision
in QE field definition.