diff options
author | Pawel Terlecki <pawel.terlecki@mongodb.com> | 2019-03-28 17:05:59 -0400 |
---|---|---|
committer | Pawel Terlecki <pawel.terlecki@mongodb.com> | 2019-04-12 20:12:32 -0400 |
commit | 008e0e0abcdcdae60a3fee23fb0a17a7c3b0be0d (patch) | |
tree | 0ab29c6db414803c23222396ea96b827b9df9d54 /src/mongo/db/matcher/matcher_type_set.cpp | |
parent | a6e3a3b544b874455ad8a98dbc12bfee5098ea25 (diff) | |
download | mongo-008e0e0abcdcdae60a3fee23fb0a17a7c3b0be0d.tar.gz |
SERVER-39492 Allow array of BSON types in encrypt.bsonType specification
Changed the IDL definition of EncryptionInfo.bsonType to use a custom type based on
MatcherTypeSet. Since it is a pretty generic type we could move it to
basic_types.idl.
Changed InternalSchemaBinDataEncryptedTypeExpression to use
MatcherTypeSet as well, rather than a single type. Parsing logic of
MatcherTypeSet allowed for a concise code.
Diffstat (limited to 'src/mongo/db/matcher/matcher_type_set.cpp')
-rw-r--r-- | src/mongo/db/matcher/matcher_type_set.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/mongo/db/matcher/matcher_type_set.cpp b/src/mongo/db/matcher/matcher_type_set.cpp index 44b77009034..1f37415a0b1 100644 --- a/src/mongo/db/matcher/matcher_type_set.cpp +++ b/src/mongo/db/matcher/matcher_type_set.cpp @@ -166,4 +166,13 @@ void MatcherTypeSet::toBSONArray(BSONArrayBuilder* builder) const { } } +BSONTypeSet BSONTypeSet::parseFromBSON(const BSONElement& element) { + // BSON type can be specified with a type alias, other values will be rejected. + auto typeSet = uassertStatusOK(JSONSchemaParser::parseTypeSet(element, kTypeAliasMap)); + return BSONTypeSet(typeSet); +} + +void BSONTypeSet::serializeToBSON(StringData fieldName, BSONObjBuilder* builder) const { + builder->appendArray(fieldName, _typeSet.toBSONArray()); +} } // namespace mongo |