summaryrefslogtreecommitdiff
path: root/src/mongo/db/matcher
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/matcher')
-rw-r--r--src/mongo/db/matcher/expression_always_boolean.h7
-rw-r--r--src/mongo/db/matcher/expression_array.cpp7
-rw-r--r--src/mongo/db/matcher/expression_tree.cpp1
3 files changed, 9 insertions, 6 deletions
diff --git a/src/mongo/db/matcher/expression_always_boolean.h b/src/mongo/db/matcher/expression_always_boolean.h
index 901203f9eff..054b9b417ca 100644
--- a/src/mongo/db/matcher/expression_always_boolean.h
+++ b/src/mongo/db/matcher/expression_always_boolean.h
@@ -63,8 +63,11 @@ public:
}
void serialize(BSONObjBuilder* out, SerializationOptions opts) const final {
- // TODO support 'opts.redactFieldNames.'
- out->append(name(), 1);
+ if (opts.replacementForLiteralArgs) {
+ out->append(name(), *opts.replacementForLiteralArgs);
+ } else {
+ out->append(name(), 1);
+ }
}
bool equivalent(const MatchExpression* other) const final {
diff --git a/src/mongo/db/matcher/expression_array.cpp b/src/mongo/db/matcher/expression_array.cpp
index 6ed79d1de5e..5f69a1211de 100644
--- a/src/mongo/db/matcher/expression_array.cpp
+++ b/src/mongo/db/matcher/expression_array.cpp
@@ -105,8 +105,9 @@ void ElemMatchObjectMatchExpression::debugString(StringBuilder& debug, int inden
BSONObj ElemMatchObjectMatchExpression::getSerializedRightHandSide(
boost::optional<StringData> replacementForLiteralArgs) const {
- // TODO SERVER-73673 respect and test 'replacementForLiteralArgs'.
- return BSON("$elemMatch" << _sub->serialize());
+ SerializationOptions opts;
+ opts.replacementForLiteralArgs = replacementForLiteralArgs;
+ return BSON("$elemMatch" << _sub->serialize(opts));
}
MatchExpression::ExpressionOptimizerFunc ElemMatchObjectMatchExpression::getOptimizer() const {
@@ -178,10 +179,10 @@ BSONObj ElemMatchValueMatchExpression::getSerializedRightHandSide(
boost::optional<StringData> replacementForLiteralArgs) const {
BSONObjBuilder emBob;
- // TODO SERVER-73673 respect and test 'replacementForLiteralArgs'.
for (auto&& child : _subs) {
SerializationOptions opts;
opts.includePath = false;
+ opts.replacementForLiteralArgs = replacementForLiteralArgs;
child->serialize(&emBob, opts);
}
diff --git a/src/mongo/db/matcher/expression_tree.cpp b/src/mongo/db/matcher/expression_tree.cpp
index c2778acb271..2f3f376931b 100644
--- a/src/mongo/db/matcher/expression_tree.cpp
+++ b/src/mongo/db/matcher/expression_tree.cpp
@@ -350,7 +350,6 @@ void AndMatchExpression::serialize(BSONObjBuilder* out, SerializationOptions opt
return;
}
- // TODO SERVER-73673 this looks correct - just need to test.
BSONArrayBuilder arrBob(out->subarrayStart("$and"));
_listToBSON(&arrBob, opts);
arrBob.doneFast();