summaryrefslogtreecommitdiff
path: root/src/mongo/db/matcher/schema
diff options
context:
space:
mode:
authorLucas de Castro Borges <lucas@gnuabordo.com.br>2025-02-11 15:07:35 -0300
committerLucas de Castro Borges <lucas@gnuabordo.com.br>2025-02-11 15:07:35 -0300
commit4cb8841196d0625dfa3825aa326f071cd27c7b8b (patch)
tree1682a647d4463397c119183369ae6f750d5fdcff /src/mongo/db/matcher/schema
parentaa03c6362cbaa767638e6eed9b031d86dd2643d1 (diff)
parent8f0827553e09872941945a093b647a4211a9db7f (diff)
Update upstream source from tag 'upstream/6.0.0'master
Update to upstream version '6.0.0' with Debian dir 5604a80ec1c96ca76f25f40d78e6ef855abec322
Diffstat (limited to 'src/mongo/db/matcher/schema')
-rw-r--r--src/mongo/db/matcher/schema/assert_serializes_to.h8
-rw-r--r--src/mongo/db/matcher/schema/expression_internal_schema_all_elem_match_from_index.cpp16
-rw-r--r--src/mongo/db/matcher/schema/expression_internal_schema_all_elem_match_from_index.h4
-rw-r--r--src/mongo/db/matcher/schema/expression_internal_schema_all_elem_match_from_index_test.cpp1
-rw-r--r--src/mongo/db/matcher/schema/expression_internal_schema_allowed_properties.cpp22
-rw-r--r--src/mongo/db/matcher/schema/expression_internal_schema_allowed_properties.h4
-rw-r--r--src/mongo/db/matcher/schema/expression_internal_schema_eq.cpp14
-rw-r--r--src/mongo/db/matcher/schema/expression_internal_schema_eq.h4
-rw-r--r--src/mongo/db/matcher/schema/expression_internal_schema_fmod.cpp11
-rw-r--r--src/mongo/db/matcher/schema/expression_internal_schema_fmod.h4
-rw-r--r--src/mongo/db/matcher/schema/expression_internal_schema_match_array_index.cpp24
-rw-r--r--src/mongo/db/matcher/schema/expression_internal_schema_match_array_index.h4
-rw-r--r--src/mongo/db/matcher/schema/expression_internal_schema_num_array_items.cpp7
-rw-r--r--src/mongo/db/matcher/schema/expression_internal_schema_num_array_items.h4
-rw-r--r--src/mongo/db/matcher/schema/expression_internal_schema_num_properties.cpp5
-rw-r--r--src/mongo/db/matcher/schema/expression_internal_schema_num_properties.h4
-rw-r--r--src/mongo/db/matcher/schema/expression_internal_schema_object_match.cpp9
-rw-r--r--src/mongo/db/matcher/schema/expression_internal_schema_object_match.h4
-rw-r--r--src/mongo/db/matcher/schema/expression_internal_schema_root_doc_eq.cpp4
-rw-r--r--src/mongo/db/matcher/schema/expression_internal_schema_root_doc_eq.h4
-rw-r--r--src/mongo/db/matcher/schema/expression_internal_schema_str_length.cpp7
-rw-r--r--src/mongo/db/matcher/schema/expression_internal_schema_str_length.h4
-rw-r--r--src/mongo/db/matcher/schema/expression_internal_schema_unique_items.cpp9
-rw-r--r--src/mongo/db/matcher/schema/expression_internal_schema_unique_items.h4
-rw-r--r--src/mongo/db/matcher/schema/expression_internal_schema_xor.cpp6
-rw-r--r--src/mongo/db/matcher/schema/expression_internal_schema_xor.h4
-rw-r--r--src/mongo/db/matcher/schema/object_keywords_test.cpp4
27 files changed, 92 insertions, 103 deletions
diff --git a/src/mongo/db/matcher/schema/assert_serializes_to.h b/src/mongo/db/matcher/schema/assert_serializes_to.h
index 7f9b3d14292..e62b5e62e1d 100644
--- a/src/mongo/db/matcher/schema/assert_serializes_to.h
+++ b/src/mongo/db/matcher/schema/assert_serializes_to.h
@@ -34,9 +34,11 @@ namespace mongo {
/**
* Asserts that the given MatchExpression 'match' serializes to the BSONObj 'expected'.
*/
-#define ASSERT_SERIALIZES_TO(match, expected) \
- do { \
- ASSERT_BSONOBJ_EQ(match->serialize(), expected); \
+#define ASSERT_SERIALIZES_TO(match, expected) \
+ do { \
+ BSONObjBuilder bob; \
+ match->serialize(&bob, true); \
+ ASSERT_BSONOBJ_EQ(bob.obj(), expected); \
} while (false)
} // namespace mongo
diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_all_elem_match_from_index.cpp b/src/mongo/db/matcher/schema/expression_internal_schema_all_elem_match_from_index.cpp
index caf39e7fcc4..27b2adae68d 100644
--- a/src/mongo/db/matcher/schema/expression_internal_schema_all_elem_match_from_index.cpp
+++ b/src/mongo/db/matcher/schema/expression_internal_schema_all_elem_match_from_index.cpp
@@ -76,11 +76,17 @@ void InternalSchemaAllElemMatchFromIndexMatchExpression::debugString(StringBuild
_expression->getFilter()->debugString(debug, indentationLevel + 1);
}
-void InternalSchemaAllElemMatchFromIndexMatchExpression::appendSerializedRightHandSide(
- BSONObjBuilder* bob, const SerializationOptions& opts, bool includePath) const {
- bob->append(kName,
- BSON_ARRAY(opts.serializeLiteral(_index)
- << _expression->getFilter()->serialize(opts, includePath)));
+BSONObj InternalSchemaAllElemMatchFromIndexMatchExpression::getSerializedRightHandSide() const {
+ BSONObjBuilder allElemMatchBob;
+ BSONArrayBuilder subArray(allElemMatchBob.subarrayStart(kName));
+ subArray.append(_index);
+ {
+ BSONObjBuilder eBuilder(subArray.subobjStart());
+ _expression->getFilter()->serialize(&eBuilder, true);
+ eBuilder.doneFast();
+ }
+ subArray.doneFast();
+ return allElemMatchBob.obj();
}
MatchExpression::ExpressionOptimizerFunc
diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_all_elem_match_from_index.h b/src/mongo/db/matcher/schema/expression_internal_schema_all_elem_match_from_index.h
index 1d1ff14d6c0..0a613b23303 100644
--- a/src/mongo/db/matcher/schema/expression_internal_schema_all_elem_match_from_index.h
+++ b/src/mongo/db/matcher/schema/expression_internal_schema_all_elem_match_from_index.h
@@ -77,9 +77,7 @@ public:
void debugString(StringBuilder& debug, int indentationLevel) const final;
- void appendSerializedRightHandSide(BSONObjBuilder* bob,
- const SerializationOptions& opts = {},
- bool includePath = true) const final;
+ BSONObj getSerializedRightHandSide() const final;
bool equivalent(const MatchExpression* other) const final;
diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_all_elem_match_from_index_test.cpp b/src/mongo/db/matcher/schema/expression_internal_schema_all_elem_match_from_index_test.cpp
index b3b3234778d..49e1b3b0235 100644
--- a/src/mongo/db/matcher/schema/expression_internal_schema_all_elem_match_from_index_test.cpp
+++ b/src/mongo/db/matcher/schema/expression_internal_schema_all_elem_match_from_index_test.cpp
@@ -135,5 +135,6 @@ DEATH_TEST_REGEX(InternalSchemaAllElemMatchFromIndexMatchExpression,
objMatch.getValue()->getChild(1);
}
+
} // namespace
} // namespace mongo
diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_allowed_properties.cpp b/src/mongo/db/matcher/schema/expression_internal_schema_allowed_properties.cpp
index 5a6471e2155..64b34aafc3a 100644
--- a/src/mongo/db/matcher/schema/expression_internal_schema_allowed_properties.cpp
+++ b/src/mongo/db/matcher/schema/expression_internal_schema_allowed_properties.cpp
@@ -59,7 +59,7 @@ void InternalSchemaAllowedPropertiesMatchExpression::debugString(StringBuilder&
_debugAddSpace(debug, indentationLevel);
BSONObjBuilder builder;
- serialize(&builder, {});
+ serialize(&builder, true);
debug << builder.obj().toString() << "\n";
const auto* tag = getTag();
@@ -128,29 +128,29 @@ bool InternalSchemaAllowedPropertiesMatchExpression::_matchesBSONObj(const BSONO
}
void InternalSchemaAllowedPropertiesMatchExpression::serialize(BSONObjBuilder* builder,
- const SerializationOptions& opts,
bool includePath) const {
BSONObjBuilder expressionBuilder(
builder->subobjStart(InternalSchemaAllowedPropertiesMatchExpression::kName));
std::vector<StringData> sortedProperties(_properties.begin(), _properties.end());
std::sort(sortedProperties.begin(), sortedProperties.end());
- opts.appendLiteral(&expressionBuilder, "properties", sortedProperties);
- // This will be serialized to "i", which is the parser chosen namePlaceholder. Using this
- // unmodified will have a similar effect to serializing to "?", however it preserves round trip
- // parsing.
+ expressionBuilder.append("properties", sortedProperties);
+
expressionBuilder.append("namePlaceholder", _namePlaceholder);
BSONArrayBuilder patternPropertiesBuilder(expressionBuilder.subarrayStart("patternProperties"));
- for (auto&& [pattern, expression] : _patternProperties) {
- patternPropertiesBuilder << BSON(
- "regex" << opts.serializeLiteral(BSONRegEx(pattern.rawRegex)) << "expression"
- << expression->getFilter()->serialize(opts, includePath));
+ for (auto&& item : _patternProperties) {
+ BSONObjBuilder itemBuilder(patternPropertiesBuilder.subobjStart());
+ itemBuilder.appendRegex("regex", item.first.rawRegex);
+
+ BSONObjBuilder subexpressionBuilder(itemBuilder.subobjStart("expression"));
+ item.second->getFilter()->serialize(&subexpressionBuilder, includePath);
+ subexpressionBuilder.doneFast();
}
patternPropertiesBuilder.doneFast();
BSONObjBuilder otherwiseBuilder(expressionBuilder.subobjStart("otherwise"));
- _otherwise->getFilter()->serialize(&otherwiseBuilder, opts, includePath);
+ _otherwise->getFilter()->serialize(&otherwiseBuilder, includePath);
otherwiseBuilder.doneFast();
expressionBuilder.doneFast();
}
diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_allowed_properties.h b/src/mongo/db/matcher/schema/expression_internal_schema_allowed_properties.h
index ae6de80a7f8..e95d0582d15 100644
--- a/src/mongo/db/matcher/schema/expression_internal_schema_allowed_properties.h
+++ b/src/mongo/db/matcher/schema/expression_internal_schema_allowed_properties.h
@@ -136,9 +136,7 @@ public:
bool matches(const MatchableDocument* doc, MatchDetails* details) const final;
bool matchesSingleElement(const BSONElement& element, MatchDetails* details) const final;
- void serialize(BSONObjBuilder* builder,
- const SerializationOptions& opts = {},
- bool includePath = true) const final;
+ void serialize(BSONObjBuilder* builder, bool includePath) const final;
std::unique_ptr<MatchExpression> shallowClone() const final;
diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_eq.cpp b/src/mongo/db/matcher/schema/expression_internal_schema_eq.cpp
index 31f5812256f..263b23cc4e9 100644
--- a/src/mongo/db/matcher/schema/expression_internal_schema_eq.cpp
+++ b/src/mongo/db/matcher/schema/expression_internal_schema_eq.cpp
@@ -69,16 +69,10 @@ void InternalSchemaEqMatchExpression::debugString(StringBuilder& debug,
debug << "\n";
}
-void InternalSchemaEqMatchExpression::appendSerializedRightHandSide(
- BSONObjBuilder* bob, const SerializationOptions& opts, bool includePath) const {
- if (opts.literalPolicy != LiteralSerializationPolicy::kUnchanged && _rhsElem.isABSONObj()) {
- BSONObjBuilder exprSpec(bob->subobjStart(kName));
- opts.addHmacedObjToBuilder(&exprSpec, _rhsElem.Obj());
- exprSpec.doneFast();
- return;
- }
- // If the element is not an object it must be a literal.
- opts.appendLiteral(bob, kName, _rhsElem);
+BSONObj InternalSchemaEqMatchExpression::getSerializedRightHandSide() const {
+ BSONObjBuilder eqObj;
+ eqObj.appendAs(_rhsElem, kName);
+ return eqObj.obj();
}
bool InternalSchemaEqMatchExpression::equivalent(const MatchExpression* other) const {
diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_eq.h b/src/mongo/db/matcher/schema/expression_internal_schema_eq.h
index 5a24d5787d2..3f604294f60 100644
--- a/src/mongo/db/matcher/schema/expression_internal_schema_eq.h
+++ b/src/mongo/db/matcher/schema/expression_internal_schema_eq.h
@@ -59,9 +59,7 @@ public:
void debugString(StringBuilder& debug, int indentationLevel) const final;
- void appendSerializedRightHandSide(BSONObjBuilder* bob,
- const SerializationOptions& opts = {},
- bool includePath = true) const final;
+ BSONObj getSerializedRightHandSide() const final;
bool equivalent(const MatchExpression* other) const final;
diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_fmod.cpp b/src/mongo/db/matcher/schema/expression_internal_schema_fmod.cpp
index fbd267bcbbf..e86e4d0240d 100644
--- a/src/mongo/db/matcher/schema/expression_internal_schema_fmod.cpp
+++ b/src/mongo/db/matcher/schema/expression_internal_schema_fmod.cpp
@@ -76,10 +76,13 @@ void InternalSchemaFmodMatchExpression::debugString(StringBuilder& debug,
debug << "\n";
}
-void InternalSchemaFmodMatchExpression::appendSerializedRightHandSide(
- BSONObjBuilder* bob, const SerializationOptions& opts, bool includePath) const {
- bob->append("$_internalSchemaFmod"_sd,
- BSON_ARRAY(opts.serializeLiteral(_divisor) << opts.serializeLiteral(_remainder)));
+BSONObj InternalSchemaFmodMatchExpression::getSerializedRightHandSide() const {
+ BSONObjBuilder objMatchBob;
+ BSONArrayBuilder arrBuilder(objMatchBob.subarrayStart("$_internalSchemaFmod"));
+ arrBuilder.append(_divisor);
+ arrBuilder.append(_remainder);
+ arrBuilder.doneFast();
+ return objMatchBob.obj();
}
bool InternalSchemaFmodMatchExpression::equivalent(const MatchExpression* other) const {
diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_fmod.h b/src/mongo/db/matcher/schema/expression_internal_schema_fmod.h
index e808e079b27..ae147f3a4fe 100644
--- a/src/mongo/db/matcher/schema/expression_internal_schema_fmod.h
+++ b/src/mongo/db/matcher/schema/expression_internal_schema_fmod.h
@@ -58,9 +58,7 @@ public:
void debugString(StringBuilder& debug, int indentationLevel) const final;
- void appendSerializedRightHandSide(BSONObjBuilder* bob,
- const SerializationOptions& opts = {},
- bool includePath = true) const final;
+ BSONObj getSerializedRightHandSide() const final;
bool equivalent(const MatchExpression* other) const final;
diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_match_array_index.cpp b/src/mongo/db/matcher/schema/expression_internal_schema_match_array_index.cpp
index 8af85dd6436..a09ad27ff22 100644
--- a/src/mongo/db/matcher/schema/expression_internal_schema_match_array_index.cpp
+++ b/src/mongo/db/matcher/schema/expression_internal_schema_match_array_index.cpp
@@ -51,7 +51,7 @@ void InternalSchemaMatchArrayIndexMatchExpression::debugString(StringBuilder& de
_debugAddSpace(debug, indentationLevel);
BSONObjBuilder builder;
- serialize(&builder, {});
+ serialize(&builder, true);
debug << builder.obj().toString() << "\n";
const auto* tag = getTag();
@@ -72,14 +72,20 @@ bool InternalSchemaMatchArrayIndexMatchExpression::equivalent(const MatchExpress
_expression->equivalent(other->_expression.get());
}
-void InternalSchemaMatchArrayIndexMatchExpression::appendSerializedRightHandSide(
- BSONObjBuilder* bob, const SerializationOptions& opts, bool includePath) const {
- bob->append(
- kName,
- BSON(
- "index" << opts.serializeLiteral(_index) << "namePlaceholder"
- << opts.serializeFieldPathFromString(_expression->getPlaceholder().value_or(""))
- << "expression" << _expression->getFilter()->serialize(opts, includePath)));
+BSONObj InternalSchemaMatchArrayIndexMatchExpression::getSerializedRightHandSide() const {
+ BSONObjBuilder objBuilder;
+ {
+ BSONObjBuilder matchArrayElemSubobj(objBuilder.subobjStart(kName));
+ matchArrayElemSubobj.append("index", _index);
+ matchArrayElemSubobj.append("namePlaceholder", _expression->getPlaceholder().value_or(""));
+ {
+ BSONObjBuilder subexprSubObj(matchArrayElemSubobj.subobjStart("expression"));
+ _expression->getFilter()->serialize(&subexprSubObj, true);
+ subexprSubObj.doneFast();
+ }
+ matchArrayElemSubobj.doneFast();
+ }
+ return objBuilder.obj();
}
std::unique_ptr<MatchExpression> InternalSchemaMatchArrayIndexMatchExpression::shallowClone()
diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_match_array_index.h b/src/mongo/db/matcher/schema/expression_internal_schema_match_array_index.h
index cea0149a028..8fff1225bf3 100644
--- a/src/mongo/db/matcher/schema/expression_internal_schema_match_array_index.h
+++ b/src/mongo/db/matcher/schema/expression_internal_schema_match_array_index.h
@@ -73,9 +73,7 @@ public:
return _expression->matchesBSONElement(element, details);
}
- void appendSerializedRightHandSide(BSONObjBuilder* bob,
- const SerializationOptions& opts = {},
- bool includePath = true) const final;
+ BSONObj getSerializedRightHandSide() const final;
std::unique_ptr<MatchExpression> shallowClone() const final;
diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_num_array_items.cpp b/src/mongo/db/matcher/schema/expression_internal_schema_num_array_items.cpp
index c6d20f63409..6fde9a327cf 100644
--- a/src/mongo/db/matcher/schema/expression_internal_schema_num_array_items.cpp
+++ b/src/mongo/db/matcher/schema/expression_internal_schema_num_array_items.cpp
@@ -56,9 +56,10 @@ void InternalSchemaNumArrayItemsMatchExpression::debugString(StringBuilder& debu
debug << "\n";
}
-void InternalSchemaNumArrayItemsMatchExpression::appendSerializedRightHandSide(
- BSONObjBuilder* bob, const SerializationOptions& opts, bool includePath) const {
- opts.appendLiteral(bob, _name, _numItems);
+BSONObj InternalSchemaNumArrayItemsMatchExpression::getSerializedRightHandSide() const {
+ BSONObjBuilder objBuilder;
+ objBuilder.append(_name, _numItems);
+ return objBuilder.obj();
}
bool InternalSchemaNumArrayItemsMatchExpression::equivalent(const MatchExpression* other) const {
diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_num_array_items.h b/src/mongo/db/matcher/schema/expression_internal_schema_num_array_items.h
index e566692b642..99ed79ec5d6 100644
--- a/src/mongo/db/matcher/schema/expression_internal_schema_num_array_items.h
+++ b/src/mongo/db/matcher/schema/expression_internal_schema_num_array_items.h
@@ -52,9 +52,7 @@ public:
void debugString(StringBuilder& debug, int indentationLevel) const final;
- void appendSerializedRightHandSide(BSONObjBuilder* bob,
- const SerializationOptions& opts = {},
- bool includePath = true) const final;
+ BSONObj getSerializedRightHandSide() const final;
bool equivalent(const MatchExpression* other) const final;
diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_num_properties.cpp b/src/mongo/db/matcher/schema/expression_internal_schema_num_properties.cpp
index 91b764dd8f5..e640a58ec71 100644
--- a/src/mongo/db/matcher/schema/expression_internal_schema_num_properties.cpp
+++ b/src/mongo/db/matcher/schema/expression_internal_schema_num_properties.cpp
@@ -37,14 +37,13 @@ void InternalSchemaNumPropertiesMatchExpression::debugString(StringBuilder& debu
int indentationLevel) const {
_debugAddSpace(debug, indentationLevel);
BSONObjBuilder builder;
- serialize(&builder, {});
+ serialize(&builder, true);
debug << builder.obj().toString() << "\n";
}
void InternalSchemaNumPropertiesMatchExpression::serialize(BSONObjBuilder* out,
- const SerializationOptions& opts,
bool includePath) const {
- opts.appendLiteral(out, _name, _numProperties);
+ out->append(_name, _numProperties);
}
bool InternalSchemaNumPropertiesMatchExpression::equivalent(const MatchExpression* other) const {
diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_num_properties.h b/src/mongo/db/matcher/schema/expression_internal_schema_num_properties.h
index 679aaaca609..29fd4fc6145 100644
--- a/src/mongo/db/matcher/schema/expression_internal_schema_num_properties.h
+++ b/src/mongo/db/matcher/schema/expression_internal_schema_num_properties.h
@@ -71,9 +71,7 @@ public:
void debugString(StringBuilder& debug, int indentationLevel) const final;
- void serialize(BSONObjBuilder* out,
- const SerializationOptions& opts = {},
- bool includePath = true) const final;
+ void serialize(BSONObjBuilder* out, bool includePath) const final;
bool equivalent(const MatchExpression* other) const final;
diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_object_match.cpp b/src/mongo/db/matcher/schema/expression_internal_schema_object_match.cpp
index 317c316374d..ec5a0943fad 100644
--- a/src/mongo/db/matcher/schema/expression_internal_schema_object_match.cpp
+++ b/src/mongo/db/matcher/schema/expression_internal_schema_object_match.cpp
@@ -61,9 +61,12 @@ void InternalSchemaObjectMatchExpression::debugString(StringBuilder& debug,
_sub->debugString(debug, indentationLevel + 1);
}
-void InternalSchemaObjectMatchExpression::appendSerializedRightHandSide(
- BSONObjBuilder* bob, const SerializationOptions& opts, bool includePath) const {
- bob->append(kName, _sub->serialize(opts, includePath));
+BSONObj InternalSchemaObjectMatchExpression::getSerializedRightHandSide() const {
+ BSONObjBuilder objMatchBob;
+ BSONObjBuilder subBob(objMatchBob.subobjStart(kName));
+ _sub->serialize(&subBob, true);
+ subBob.doneFast();
+ return objMatchBob.obj();
}
bool InternalSchemaObjectMatchExpression::equivalent(const MatchExpression* other) const {
diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_object_match.h b/src/mongo/db/matcher/schema/expression_internal_schema_object_match.h
index a41190d9545..93b6e1b765e 100644
--- a/src/mongo/db/matcher/schema/expression_internal_schema_object_match.h
+++ b/src/mongo/db/matcher/schema/expression_internal_schema_object_match.h
@@ -49,9 +49,7 @@ public:
void debugString(StringBuilder& debug, int indentationLevel = 0) const final;
- void appendSerializedRightHandSide(BSONObjBuilder* bob,
- const SerializationOptions& opts = {},
- bool includePath = true) const final;
+ BSONObj getSerializedRightHandSide() const final;
bool equivalent(const MatchExpression* other) const final;
diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_root_doc_eq.cpp b/src/mongo/db/matcher/schema/expression_internal_schema_root_doc_eq.cpp
index 300d1a49109..c4b1e3f7aa2 100644
--- a/src/mongo/db/matcher/schema/expression_internal_schema_root_doc_eq.cpp
+++ b/src/mongo/db/matcher/schema/expression_internal_schema_root_doc_eq.cpp
@@ -55,11 +55,9 @@ void InternalSchemaRootDocEqMatchExpression::debugString(StringBuilder& debug,
}
void InternalSchemaRootDocEqMatchExpression::serialize(BSONObjBuilder* out,
- const SerializationOptions& opts,
bool includePath) const {
BSONObjBuilder subObj(out->subobjStart(kName));
- SerializationOptions options = opts;
- options.addHmacedObjToBuilder(&subObj, _rhsObj);
+ subObj.appendElements(_rhsObj);
subObj.doneFast();
}
diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_root_doc_eq.h b/src/mongo/db/matcher/schema/expression_internal_schema_root_doc_eq.h
index 4418e101d43..62dfb6d66a2 100644
--- a/src/mongo/db/matcher/schema/expression_internal_schema_root_doc_eq.h
+++ b/src/mongo/db/matcher/schema/expression_internal_schema_root_doc_eq.h
@@ -72,9 +72,7 @@ public:
void debugString(StringBuilder& debug, int indentationLevel = 0) const final;
- void serialize(BSONObjBuilder* out,
- const SerializationOptions& opts = {},
- bool includePath = true) const final;
+ void serialize(BSONObjBuilder* out, bool includePath) const final;
bool equivalent(const MatchExpression* other) const final;
diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_str_length.cpp b/src/mongo/db/matcher/schema/expression_internal_schema_str_length.cpp
index bdf2f5c2c4c..87d6396fd0f 100644
--- a/src/mongo/db/matcher/schema/expression_internal_schema_str_length.cpp
+++ b/src/mongo/db/matcher/schema/expression_internal_schema_str_length.cpp
@@ -56,9 +56,10 @@ void InternalSchemaStrLengthMatchExpression::debugString(StringBuilder& debug,
debug << "\n";
}
-void InternalSchemaStrLengthMatchExpression::appendSerializedRightHandSide(
- BSONObjBuilder* bob, const SerializationOptions& opts, bool includePath) const {
- opts.appendLiteral(bob, _name, _strLen);
+BSONObj InternalSchemaStrLengthMatchExpression::getSerializedRightHandSide() const {
+ BSONObjBuilder objBuilder;
+ objBuilder.append(_name, _strLen);
+ return objBuilder.obj();
}
bool InternalSchemaStrLengthMatchExpression::equivalent(const MatchExpression* other) const {
diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_str_length.h b/src/mongo/db/matcher/schema/expression_internal_schema_str_length.h
index 6796c532972..43483be1ce3 100644
--- a/src/mongo/db/matcher/schema/expression_internal_schema_str_length.h
+++ b/src/mongo/db/matcher/schema/expression_internal_schema_str_length.h
@@ -62,9 +62,7 @@ public:
void debugString(StringBuilder& debug, int indentationLevel) const final;
- void appendSerializedRightHandSide(BSONObjBuilder* bob,
- const SerializationOptions& opts = {},
- bool includePath = true) const final;
+ BSONObj getSerializedRightHandSide() const final;
bool equivalent(const MatchExpression* other) const final;
diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_unique_items.cpp b/src/mongo/db/matcher/schema/expression_internal_schema_unique_items.cpp
index afe8f8422a9..f78dca0c37f 100644
--- a/src/mongo/db/matcher/schema/expression_internal_schema_unique_items.cpp
+++ b/src/mongo/db/matcher/schema/expression_internal_schema_unique_items.cpp
@@ -39,7 +39,7 @@ void InternalSchemaUniqueItemsMatchExpression::debugString(StringBuilder& debug,
_debugAddSpace(debug, indentationLevel);
BSONObjBuilder builder;
- serialize(&builder, {});
+ serialize(&builder, true);
debug << builder.obj().toString() << "\n";
const auto* tag = getTag();
@@ -59,9 +59,10 @@ bool InternalSchemaUniqueItemsMatchExpression::equivalent(const MatchExpression*
return path() == other->path();
}
-void InternalSchemaUniqueItemsMatchExpression::appendSerializedRightHandSide(
- BSONObjBuilder* bob, const SerializationOptions& opts, bool includePath) const {
- bob->append(kName, true);
+BSONObj InternalSchemaUniqueItemsMatchExpression::getSerializedRightHandSide() const {
+ BSONObjBuilder bob;
+ bob.append(kName, true);
+ return bob.obj();
}
std::unique_ptr<MatchExpression> InternalSchemaUniqueItemsMatchExpression::shallowClone() const {
diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_unique_items.h b/src/mongo/db/matcher/schema/expression_internal_schema_unique_items.h
index dc6e76af59f..ddb86c89403 100644
--- a/src/mongo/db/matcher/schema/expression_internal_schema_unique_items.h
+++ b/src/mongo/db/matcher/schema/expression_internal_schema_unique_items.h
@@ -86,9 +86,7 @@ public:
bool equivalent(const MatchExpression* other) const final;
- void appendSerializedRightHandSide(BSONObjBuilder* bob,
- const SerializationOptions& opts = {},
- bool includePath = true) const final;
+ BSONObj getSerializedRightHandSide() const final;
std::unique_ptr<MatchExpression> shallowClone() const final;
diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_xor.cpp b/src/mongo/db/matcher/schema/expression_internal_schema_xor.cpp
index 04c5bbb045a..ad265266f52 100644
--- a/src/mongo/db/matcher/schema/expression_internal_schema_xor.cpp
+++ b/src/mongo/db/matcher/schema/expression_internal_schema_xor.cpp
@@ -73,10 +73,8 @@ void InternalSchemaXorMatchExpression::debugString(StringBuilder& debug,
_debugList(debug, indentationLevel);
}
-void InternalSchemaXorMatchExpression::serialize(BSONObjBuilder* out,
- const SerializationOptions& opts,
- bool includePath) const {
+void InternalSchemaXorMatchExpression::serialize(BSONObjBuilder* out, bool includePath) const {
BSONArrayBuilder arrBob(out->subarrayStart(kName));
- _listToBSON(&arrBob, opts, includePath);
+ _listToBSON(&arrBob, includePath);
}
} // namespace mongo
diff --git a/src/mongo/db/matcher/schema/expression_internal_schema_xor.h b/src/mongo/db/matcher/schema/expression_internal_schema_xor.h
index 57825bff060..928a13413f1 100644
--- a/src/mongo/db/matcher/schema/expression_internal_schema_xor.h
+++ b/src/mongo/db/matcher/schema/expression_internal_schema_xor.h
@@ -69,9 +69,7 @@ public:
void debugString(StringBuilder& debug, int indentationLevel = 0) const final;
- void serialize(BSONObjBuilder* out,
- const SerializationOptions& opts = {},
- bool includePath = true) const final;
+ void serialize(BSONObjBuilder* out, bool includePath) const final;
void acceptVisitor(MatchExpressionMutableVisitor* visitor) final {
visitor->visit(this);
diff --git a/src/mongo/db/matcher/schema/object_keywords_test.cpp b/src/mongo/db/matcher/schema/object_keywords_test.cpp
index 468c0bb8cc9..73bb4b7d7dd 100644
--- a/src/mongo/db/matcher/schema/object_keywords_test.cpp
+++ b/src/mongo/db/matcher/schema/object_keywords_test.cpp
@@ -256,11 +256,11 @@ TEST(JSONSchemaObjectKeywordTest, SharedJsonAndBsonTypeAliasesTranslateIdentical
ASSERT_OK(bsonTypeResult.getStatus());
BSONObjBuilder typeBuilder;
- MatchExpression::optimize(std::move(typeResult.getValue()))->serialize(&typeBuilder, {});
+ MatchExpression::optimize(std::move(typeResult.getValue()))->serialize(&typeBuilder, true);
BSONObjBuilder bsonTypeBuilder;
MatchExpression::optimize(std::move(bsonTypeResult.getValue()))
- ->serialize(&bsonTypeBuilder, {});
+ ->serialize(&bsonTypeBuilder, true);
ASSERT_BSONOBJ_EQ(typeBuilder.obj(), bsonTypeBuilder.obj());
}