summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/pipeline')
-rw-r--r--src/mongo/db/pipeline/accumulator_test.cpp8
-rw-r--r--src/mongo/db/pipeline/aggregation_context_fixture.h4
-rw-r--r--src/mongo/db/pipeline/document_source_bucket_auto.cpp5
-rw-r--r--src/mongo/db/pipeline/document_source_change_stream_oplog_match.cpp2
-rw-r--r--src/mongo/db/pipeline/document_source_change_stream_unwind_transaction.cpp2
-rw-r--r--src/mongo/db/pipeline/document_source_coll_stats.cpp2
-rw-r--r--src/mongo/db/pipeline/document_source_cursor.cpp2
-rw-r--r--src/mongo/db/pipeline/document_source_densify.cpp11
-rw-r--r--src/mongo/db/pipeline/document_source_densify_test.cpp4
-rw-r--r--src/mongo/db/pipeline/document_source_exchange.cpp2
-rw-r--r--src/mongo/db/pipeline/document_source_facet.cpp2
-rw-r--r--src/mongo/db/pipeline/document_source_geo_near.cpp8
-rw-r--r--src/mongo/db/pipeline/document_source_graph_lookup.cpp2
-rw-r--r--src/mongo/db/pipeline/document_source_group_base.cpp10
-rw-r--r--src/mongo/db/pipeline/document_source_index_stats.cpp2
-rw-r--r--src/mongo/db/pipeline/document_source_internal_all_collection_stats.cpp4
-rw-r--r--src/mongo/db/pipeline/document_source_internal_compute_geo_near_distance.cpp5
-rw-r--r--src/mongo/db/pipeline/document_source_internal_convert_bucket_index_stats.cpp2
-rw-r--r--src/mongo/db/pipeline/document_source_internal_unpack_bucket.cpp13
-rw-r--r--src/mongo/db/pipeline/document_source_internal_unpack_bucket_test/unpack_bucket_exec_test.cpp4
-rw-r--r--src/mongo/db/pipeline/document_source_list_cached_and_active_users.h2
-rw-r--r--src/mongo/db/pipeline/document_source_list_local_sessions.h2
-rw-r--r--src/mongo/db/pipeline/document_source_list_sessions.cpp2
-rw-r--r--src/mongo/db/pipeline/document_source_lookup.cpp2
-rw-r--r--src/mongo/db/pipeline/document_source_match.cpp2
-rw-r--r--src/mongo/db/pipeline/document_source_match_test.cpp6
-rw-r--r--src/mongo/db/pipeline/document_source_merge.cpp2
-rw-r--r--src/mongo/db/pipeline/document_source_out.cpp4
-rw-r--r--src/mongo/db/pipeline/document_source_plan_cache_stats.cpp2
-rw-r--r--src/mongo/db/pipeline/document_source_plan_cache_stats_test.cpp4
-rw-r--r--src/mongo/db/pipeline/document_source_queue.cpp2
-rw-r--r--src/mongo/db/pipeline/document_source_sequential_document_cache.cpp2
-rw-r--r--src/mongo/db/pipeline/document_source_set_variable_from_subpipeline.cpp2
-rw-r--r--src/mongo/db/pipeline/document_source_set_window_fields.cpp4
-rw-r--r--src/mongo/db/pipeline/document_source_set_window_fields_test.cpp4
-rw-r--r--src/mongo/db/pipeline/document_source_single_document_transformation.cpp2
-rw-r--r--src/mongo/db/pipeline/document_source_skip.cpp2
-rw-r--r--src/mongo/db/pipeline/document_source_sort.cpp2
-rw-r--r--src/mongo/db/pipeline/document_source_streaming_group.cpp4
-rw-r--r--src/mongo/db/pipeline/document_source_telemetry.cpp12
-rw-r--r--src/mongo/db/pipeline/document_source_telemetry.h12
-rw-r--r--src/mongo/db/pipeline/document_source_union_with.cpp2
-rw-r--r--src/mongo/db/pipeline/document_source_unwind.cpp4
-rw-r--r--src/mongo/db/pipeline/expression.cpp49
-rw-r--r--src/mongo/db/pipeline/expression_field_path_test.cpp4
-rw-r--r--src/mongo/db/pipeline/expression_function_test.cpp4
-rw-r--r--src/mongo/db/pipeline/expression_let_test.cpp4
-rw-r--r--src/mongo/db/pipeline/expression_test.cpp8
-rw-r--r--src/mongo/db/pipeline/field_path.cpp14
-rw-r--r--src/mongo/db/pipeline/field_path.h5
50 files changed, 119 insertions, 145 deletions
diff --git a/src/mongo/db/pipeline/accumulator_test.cpp b/src/mongo/db/pipeline/accumulator_test.cpp
index 81c521d80fe..5a38b558fb7 100644
--- a/src/mongo/db/pipeline/accumulator_test.cpp
+++ b/src/mongo/db/pipeline/accumulator_test.cpp
@@ -1747,8 +1747,8 @@ Value parseAndSerializeAccumExpr(
SerializationOptions options;
std::string replacementChar = "?";
options.replacementForLiteralArgs = replacementChar;
- options.redactFieldNames = true;
- options.redactFieldNamesStrategy = redactFieldNameForTest;
+ options.redactIdentifiers = true;
+ options.identifierRedactionPolicy = redactFieldNameForTest;
auto expCtx = make_intrusive<ExpressionContextForTest>();
auto expr = func(expCtx.get(), obj.firstElement(), expCtx->variablesParseState);
return expr->serialize(options);
@@ -1761,8 +1761,8 @@ Document parseAndSerializeAccum(
SerializationOptions options;
std::string replacementChar = "?";
options.replacementForLiteralArgs = replacementChar;
- options.redactFieldNames = true;
- options.redactFieldNamesStrategy = redactFieldNameForTest;
+ options.redactIdentifiers = true;
+ options.identifierRedactionPolicy = redactFieldNameForTest;
auto expCtx = make_intrusive<ExpressionContextForTest>();
VariablesParseState vps = expCtx->variablesParseState;
diff --git a/src/mongo/db/pipeline/aggregation_context_fixture.h b/src/mongo/db/pipeline/aggregation_context_fixture.h
index 8ca80386393..17a921970b6 100644
--- a/src/mongo/db/pipeline/aggregation_context_fixture.h
+++ b/src/mongo/db/pipeline/aggregation_context_fixture.h
@@ -81,10 +81,10 @@ public:
SerializationOptions options;
if (performRedaction) {
options.replacementForLiteralArgs = "?";
- options.redactFieldNamesStrategy = [](StringData s) -> std::string {
+ options.identifierRedactionPolicy = [](StringData s) -> std::string {
return str::stream() << "HASH<" << s << ">";
};
- options.redactFieldNames = true;
+ options.redactIdentifiers = true;
}
std::vector<Value> serialized;
docSource.serializeToArray(serialized, options);
diff --git a/src/mongo/db/pipeline/document_source_bucket_auto.cpp b/src/mongo/db/pipeline/document_source_bucket_auto.cpp
index 80bf8034b5f..599d1d54a36 100644
--- a/src/mongo/db/pipeline/document_source_bucket_auto.cpp
+++ b/src/mongo/db/pipeline/document_source_bucket_auto.cpp
@@ -393,8 +393,9 @@ Value DocumentSourceBucketAuto::serialize(SerializationOptions opts) const {
MutableDocument outputSpec(_accumulatedFields.size());
for (auto&& accumulatedField : _accumulatedFields) {
intrusive_ptr<AccumulatorState> accum = accumulatedField.makeAccumulator();
- outputSpec[opts.serializeFieldName(accumulatedField.fieldName)] = Value(accum->serialize(
- accumulatedField.expr.initializer, accumulatedField.expr.argument, opts));
+ outputSpec[opts.serializeFieldPathFromString(accumulatedField.fieldName)] =
+ Value(accum->serialize(
+ accumulatedField.expr.initializer, accumulatedField.expr.argument, opts));
}
insides["output"] = outputSpec.freezeToValue();
diff --git a/src/mongo/db/pipeline/document_source_change_stream_oplog_match.cpp b/src/mongo/db/pipeline/document_source_change_stream_oplog_match.cpp
index db46615ce3a..8302bc3bc2a 100644
--- a/src/mongo/db/pipeline/document_source_change_stream_oplog_match.cpp
+++ b/src/mongo/db/pipeline/document_source_change_stream_oplog_match.cpp
@@ -214,7 +214,7 @@ Value DocumentSourceChangeStreamOplogMatch::serialize(SerializationOptions opts)
sub.done();
} else {
BSONObjBuilder sub(builder.subobjStart(kStageName));
- if (opts.replacementForLiteralArgs || opts.redactFieldNames) {
+ if (opts.replacementForLiteralArgs || opts.redactIdentifiers) {
sub.append(DocumentSourceChangeStreamOplogMatchSpec::kFilterFieldName,
getMatchExpression()->serialize(opts));
} else {
diff --git a/src/mongo/db/pipeline/document_source_change_stream_unwind_transaction.cpp b/src/mongo/db/pipeline/document_source_change_stream_unwind_transaction.cpp
index e0dfedd0529..0c4263238dc 100644
--- a/src/mongo/db/pipeline/document_source_change_stream_unwind_transaction.cpp
+++ b/src/mongo/db/pipeline/document_source_change_stream_unwind_transaction.cpp
@@ -141,7 +141,7 @@ Value DocumentSourceChangeStreamUnwindTransaction::serialize(SerializationOption
}
Value spec;
- if (opts.replacementForLiteralArgs || opts.redactFieldNames) {
+ if (opts.replacementForLiteralArgs || opts.redactIdentifiers) {
spec = Value(DOC(DocumentSourceChangeStreamUnwindTransactionSpec::kFilterFieldName
<< _expression->serialize(opts)));
} else {
diff --git a/src/mongo/db/pipeline/document_source_coll_stats.cpp b/src/mongo/db/pipeline/document_source_coll_stats.cpp
index b771cf08433..6e8efcca9aa 100644
--- a/src/mongo/db/pipeline/document_source_coll_stats.cpp
+++ b/src/mongo/db/pipeline/document_source_coll_stats.cpp
@@ -129,7 +129,7 @@ DocumentSource::GetNextResult DocumentSourceCollStats::doGetNext() {
}
Value DocumentSourceCollStats::serialize(SerializationOptions opts) const {
- if (opts.redactFieldNames || opts.replacementForLiteralArgs) {
+ if (opts.redactIdentifiers || opts.replacementForLiteralArgs) {
MONGO_UNIMPLEMENTED_TASSERT(7484352);
}
return Value(Document{{getSourceName(), _collStatsSpec.toBSON()}});
diff --git a/src/mongo/db/pipeline/document_source_cursor.cpp b/src/mongo/db/pipeline/document_source_cursor.cpp
index 520e999c10a..f01f2e0d347 100644
--- a/src/mongo/db/pipeline/document_source_cursor.cpp
+++ b/src/mongo/db/pipeline/document_source_cursor.cpp
@@ -210,7 +210,7 @@ void DocumentSourceCursor::recordPlanSummaryStats() {
Value DocumentSourceCursor::serialize(SerializationOptions opts) const {
auto verbosity = opts.verbosity;
- if (opts.redactFieldNames || opts.replacementForLiteralArgs) {
+ if (opts.redactIdentifiers || opts.replacementForLiteralArgs) {
MONGO_UNIMPLEMENTED_TASSERT(7484350);
}
// We never parse a DocumentSourceCursor, so we only serialize for explain.
diff --git a/src/mongo/db/pipeline/document_source_densify.cpp b/src/mongo/db/pipeline/document_source_densify.cpp
index a24ca77793d..f035cff11f7 100644
--- a/src/mongo/db/pipeline/document_source_densify.cpp
+++ b/src/mongo/db/pipeline/document_source_densify.cpp
@@ -635,13 +635,12 @@ boost::intrusive_ptr<DocumentSource> DocumentSourceInternalDensify::createFromBs
Value DocumentSourceInternalDensify::serialize(SerializationOptions opts) const {
MutableDocument spec;
- spec[kFieldFieldName] = Value(opts.serializeFieldName(_field.fullPath()));
+ spec[kFieldFieldName] = Value(opts.serializeFieldPath(_field));
std::vector<Value> serializedPartitionByFields(_partitions.size());
- std::transform(
- _partitions.begin(),
- _partitions.end(),
- serializedPartitionByFields.begin(),
- [&](FieldPath field) -> Value { return Value(opts.serializeFieldName(field.fullPath())); });
+ std::transform(_partitions.begin(),
+ _partitions.end(),
+ serializedPartitionByFields.begin(),
+ [&](FieldPath field) -> Value { return Value(opts.serializeFieldPath(field)); });
spec[kPartitionByFieldsFieldName] = Value(serializedPartitionByFields);
spec[kRangeFieldName] = _range.serialize(opts);
MutableDocument out;
diff --git a/src/mongo/db/pipeline/document_source_densify_test.cpp b/src/mongo/db/pipeline/document_source_densify_test.cpp
index 3a960afe02d..38290d12504 100644
--- a/src/mongo/db/pipeline/document_source_densify_test.cpp
+++ b/src/mongo/db/pipeline/document_source_densify_test.cpp
@@ -1320,7 +1320,7 @@ TEST_F(DensifyRedactionTest, RedactionFullBoundsWithPartitionFields) {
auto spec = fromjson(R"({
$densify: {
field: "foo",
- partitionByFields: ["a", "b", "c"],
+ partitionByFields: ["a", "b", "c.d"],
range: {
bounds: "full",
step: 100
@@ -1336,7 +1336,7 @@ TEST_F(DensifyRedactionTest, RedactionFullBoundsWithPartitionFields) {
"partitionByFields": [
"HASH<a>",
"HASH<b>",
- "HASH<c>"
+ "HASH<c>.HASH<d>"
],
"range": {
"step": "?",
diff --git a/src/mongo/db/pipeline/document_source_exchange.cpp b/src/mongo/db/pipeline/document_source_exchange.cpp
index dd23d00b94f..2d6999f4a7d 100644
--- a/src/mongo/db/pipeline/document_source_exchange.cpp
+++ b/src/mongo/db/pipeline/document_source_exchange.cpp
@@ -94,7 +94,7 @@ const char* DocumentSourceExchange::getSourceName() const {
}
Value DocumentSourceExchange::serialize(SerializationOptions opts) const {
- if (opts.redactFieldNames || opts.replacementForLiteralArgs) {
+ if (opts.redactIdentifiers || opts.replacementForLiteralArgs) {
MONGO_UNIMPLEMENTED_TASSERT(7484348);
}
return Value(DOC(getSourceName() << _exchange->getSpec().toBSON()));
diff --git a/src/mongo/db/pipeline/document_source_facet.cpp b/src/mongo/db/pipeline/document_source_facet.cpp
index f16b4c9be03..be3dfc3b646 100644
--- a/src/mongo/db/pipeline/document_source_facet.cpp
+++ b/src/mongo/db/pipeline/document_source_facet.cpp
@@ -186,7 +186,7 @@ DocumentSource::GetNextResult DocumentSourceFacet::doGetNext() {
}
Value DocumentSourceFacet::serialize(SerializationOptions opts) const {
- if (opts.redactFieldNames || opts.replacementForLiteralArgs) {
+ if (opts.redactIdentifiers || opts.replacementForLiteralArgs) {
MONGO_UNIMPLEMENTED_TASSERT(7484347);
}
diff --git a/src/mongo/db/pipeline/document_source_geo_near.cpp b/src/mongo/db/pipeline/document_source_geo_near.cpp
index 912bc29a6b4..5e966e09cd5 100644
--- a/src/mongo/db/pipeline/document_source_geo_near.cpp
+++ b/src/mongo/db/pipeline/document_source_geo_near.cpp
@@ -64,7 +64,7 @@ Value DocumentSourceGeoNear::serialize(SerializationOptions opts) const {
MutableDocument result;
if (keyFieldPath) {
- result.setField(kKeyFieldName, Value(keyFieldPath->redactedFullPath(opts)));
+ result.setField(kKeyFieldName, Value(opts.serializeFieldPath(*keyFieldPath)));
}
auto nearValue = [&]() -> Value {
@@ -76,7 +76,7 @@ Value DocumentSourceGeoNear::serialize(SerializationOptions opts) const {
}
}();
result.setField("near", nearValue);
- result.setField("distanceField", Value(distanceField->redactedFullPath(opts)));
+ result.setField("distanceField", Value(opts.serializeFieldPath(*distanceField)));
if (maxDistance) {
result.setField("maxDistance", opts.serializeLiteralValue(*maxDistance));
@@ -86,7 +86,7 @@ Value DocumentSourceGeoNear::serialize(SerializationOptions opts) const {
result.setField("minDistance", opts.serializeLiteralValue(*minDistance));
}
- if (opts.redactFieldNames || opts.replacementForLiteralArgs) {
+ if (opts.redactIdentifiers || opts.replacementForLiteralArgs) {
auto matchExpr = uassertStatusOK(MatchExpressionParser::parse(query, pExpCtx));
result.setField("query", Value(matchExpr->serialize(opts)));
} else {
@@ -98,7 +98,7 @@ Value DocumentSourceGeoNear::serialize(SerializationOptions opts) const {
}
if (includeLocs)
- result.setField("includeLocs", Value(includeLocs->redactedFullPath(opts)));
+ result.setField("includeLocs", Value(opts.serializeFieldPath(*includeLocs)));
return Value(DOC(getSourceName() << result.freeze()));
}
diff --git a/src/mongo/db/pipeline/document_source_graph_lookup.cpp b/src/mongo/db/pipeline/document_source_graph_lookup.cpp
index 244939c2d61..fb160a019a6 100644
--- a/src/mongo/db/pipeline/document_source_graph_lookup.cpp
+++ b/src/mongo/db/pipeline/document_source_graph_lookup.cpp
@@ -584,7 +584,7 @@ void DocumentSourceGraphLookUp::checkMemoryUsage() {
void DocumentSourceGraphLookUp::serializeToArray(std::vector<Value>& array,
SerializationOptions opts) const {
auto explain = opts.verbosity;
- if (opts.redactFieldNames || opts.replacementForLiteralArgs) {
+ if (opts.redactIdentifiers || opts.replacementForLiteralArgs) {
MONGO_UNIMPLEMENTED_TASSERT(7484344);
}
diff --git a/src/mongo/db/pipeline/document_source_group_base.cpp b/src/mongo/db/pipeline/document_source_group_base.cpp
index befa8986626..71c75eb00ac 100644
--- a/src/mongo/db/pipeline/document_source_group_base.cpp
+++ b/src/mongo/db/pipeline/document_source_group_base.cpp
@@ -99,7 +99,8 @@ Value DocumentSourceGroupBase::serialize(SerializationOptions opts) const {
invariant(_idExpressions.size() == _idFieldNames.size());
MutableDocument md;
for (size_t i = 0; i < _idExpressions.size(); i++) {
- md[opts.serializeFieldName(_idFieldNames[i])] = _idExpressions[i]->serialize(opts);
+ md[opts.serializeFieldPathFromString(_idFieldNames[i])] =
+ _idExpressions[i]->serialize(opts);
}
insides["_id"] = md.freezeToValue();
}
@@ -107,8 +108,9 @@ Value DocumentSourceGroupBase::serialize(SerializationOptions opts) const {
// Add the remaining fields.
for (auto&& accumulatedField : _accumulatedFields) {
intrusive_ptr<AccumulatorState> accum = accumulatedField.makeAccumulator();
- insides[opts.serializeFieldName(accumulatedField.fieldName)] = Value(accum->serialize(
- accumulatedField.expr.initializer, accumulatedField.expr.argument, opts));
+ insides[opts.serializeFieldPathFromString(accumulatedField.fieldName)] =
+ Value(accum->serialize(
+ accumulatedField.expr.initializer, accumulatedField.expr.argument, opts));
}
if (_doingMerge) {
@@ -124,7 +126,7 @@ Value DocumentSourceGroupBase::serialize(SerializationOptions opts) const {
MutableDocument md;
for (size_t i = 0; i < _accumulatedFields.size(); i++) {
- md[opts.serializeFieldName(_accumulatedFields[i].fieldName)] =
+ md[opts.serializeFieldPathFromString(_accumulatedFields[i].fieldName)] =
opts.serializeLiteralValue(static_cast<long long>(
_memoryTracker[_accumulatedFields[i].fieldName].maxMemoryBytes()));
}
diff --git a/src/mongo/db/pipeline/document_source_index_stats.cpp b/src/mongo/db/pipeline/document_source_index_stats.cpp
index d8e07355efa..f730ff9eb02 100644
--- a/src/mongo/db/pipeline/document_source_index_stats.cpp
+++ b/src/mongo/db/pipeline/document_source_index_stats.cpp
@@ -79,7 +79,7 @@ intrusive_ptr<DocumentSource> DocumentSourceIndexStats::createFromBson(
}
Value DocumentSourceIndexStats::serialize(SerializationOptions opts) const {
- if (opts.redactFieldNames || opts.replacementForLiteralArgs) {
+ if (opts.redactIdentifiers || opts.replacementForLiteralArgs) {
MONGO_UNIMPLEMENTED_TASSERT(7484342);
}
return Value(DOC(getSourceName() << Document()));
diff --git a/src/mongo/db/pipeline/document_source_internal_all_collection_stats.cpp b/src/mongo/db/pipeline/document_source_internal_all_collection_stats.cpp
index 27f74f41025..5eb4e7625aa 100644
--- a/src/mongo/db/pipeline/document_source_internal_all_collection_stats.cpp
+++ b/src/mongo/db/pipeline/document_source_internal_all_collection_stats.cpp
@@ -129,7 +129,7 @@ Pipeline::SourceContainer::iterator DocumentSourceInternalAllCollectionStats::do
void DocumentSourceInternalAllCollectionStats::serializeToArray(std::vector<Value>& array,
SerializationOptions opts) const {
auto explain = opts.verbosity;
- if (opts.redactFieldNames || opts.replacementForLiteralArgs) {
+ if (opts.redactIdentifiers || opts.replacementForLiteralArgs) {
MONGO_UNIMPLEMENTED_TASSERT(7484341);
}
if (explain) {
@@ -170,7 +170,7 @@ const char* DocumentSourceInternalAllCollectionStats::getSourceName() const {
}
Value DocumentSourceInternalAllCollectionStats::serialize(SerializationOptions opts) const {
- if (opts.redactFieldNames || opts.replacementForLiteralArgs) {
+ if (opts.redactIdentifiers || opts.replacementForLiteralArgs) {
MONGO_UNIMPLEMENTED_TASSERT(7484340);
}
return Value(Document{{getSourceName(), _internalAllCollectionStatsSpec.toBSON()}});
diff --git a/src/mongo/db/pipeline/document_source_internal_compute_geo_near_distance.cpp b/src/mongo/db/pipeline/document_source_internal_compute_geo_near_distance.cpp
index cb5d89b632f..65681cdca94 100644
--- a/src/mongo/db/pipeline/document_source_internal_compute_geo_near_distance.cpp
+++ b/src/mongo/db/pipeline/document_source_internal_compute_geo_near_distance.cpp
@@ -142,14 +142,13 @@ DocumentSource::GetNextResult DocumentSourceInternalGeoNearDistance::doGetNext()
}
Value DocumentSourceInternalGeoNearDistance::serialize(SerializationOptions opts) const {
-
MutableDocument out;
out.setField(DocumentSourceInternalGeoNearDistance::kNearFieldName,
opts.serializeLiteralValue(_coords));
out.setField(DocumentSourceInternalGeoNearDistance::kKeyFieldName,
- Value(opts.serializeFieldName(_key)));
+ Value(opts.serializeFieldPathFromString(_key)));
out.setField(DocumentSourceInternalGeoNearDistance::kDistanceFieldFieldName,
- Value(opts.serializeFieldName(_distanceField.fullPath())));
+ Value(opts.serializeFieldPath(_distanceField)));
out.setField(DocumentSourceInternalGeoNearDistance::kDistanceMultiplierFieldName,
opts.serializeLiteralValue(_distanceMultiplier));
diff --git a/src/mongo/db/pipeline/document_source_internal_convert_bucket_index_stats.cpp b/src/mongo/db/pipeline/document_source_internal_convert_bucket_index_stats.cpp
index 4a53382a23d..6f4e0e58ea6 100644
--- a/src/mongo/db/pipeline/document_source_internal_convert_bucket_index_stats.cpp
+++ b/src/mongo/db/pipeline/document_source_internal_convert_bucket_index_stats.cpp
@@ -146,7 +146,7 @@ boost::intrusive_ptr<DocumentSource> DocumentSourceInternalConvertBucketIndexSta
}
Value DocumentSourceInternalConvertBucketIndexStats::serialize(SerializationOptions opts) const {
- if (opts.redactFieldNames || opts.replacementForLiteralArgs) {
+ if (opts.redactIdentifiers || opts.replacementForLiteralArgs) {
MONGO_UNIMPLEMENTED_TASSERT(7484337);
}
diff --git a/src/mongo/db/pipeline/document_source_internal_unpack_bucket.cpp b/src/mongo/db/pipeline/document_source_internal_unpack_bucket.cpp
index d05ae51d35b..d338b88bedb 100644
--- a/src/mongo/db/pipeline/document_source_internal_unpack_bucket.cpp
+++ b/src/mongo/db/pipeline/document_source_internal_unpack_bucket.cpp
@@ -489,7 +489,7 @@ void DocumentSourceInternalUnpackBucket::serializeToArray(std::vector<Value>& ar
const auto& spec = _bucketUnpacker.bucketSpec();
std::vector<Value> fields;
for (auto&& field : spec.fieldSet()) {
- fields.emplace_back(opts.serializeFieldName(field));
+ fields.emplace_back(opts.serializeFieldPathFromString(field));
}
if (((_bucketUnpacker.includeMetaField() &&
_bucketUnpacker.behavior() == BucketSpec::Behavior::kInclude) ||
@@ -498,12 +498,14 @@ void DocumentSourceInternalUnpackBucket::serializeToArray(std::vector<Value>& ar
std::find(spec.computedMetaProjFields().cbegin(),
spec.computedMetaProjFields().cend(),
*spec.metaField()) == spec.computedMetaProjFields().cend())
- fields.emplace_back(opts.serializeFieldName(*spec.metaField()));
+ fields.emplace_back(opts.serializeFieldPathFromString(*spec.metaField()));
out.addField(behavior, Value{std::move(fields)});
- out.addField(timeseries::kTimeFieldName, Value{opts.serializeFieldName(spec.timeField())});
+ out.addField(timeseries::kTimeFieldName,
+ Value{opts.serializeFieldPathFromString(spec.timeField())});
if (spec.metaField()) {
- out.addField(timeseries::kMetaFieldName, Value{opts.serializeFieldName(*spec.metaField())});
+ out.addField(timeseries::kMetaFieldName,
+ Value{opts.serializeFieldPathFromString(*spec.metaField())});
}
out.addField(kBucketMaxSpanSeconds, opts.serializeLiteralValue(Value{_bucketMaxSpanSeconds}));
if (_assumeNoMixedSchemaData)
@@ -525,7 +527,8 @@ void DocumentSourceInternalUnpackBucket::serializeToArray(std::vector<Value>& ar
spec.computedMetaProjFields().cend(),
std::back_inserter(compFields),
[opts](auto&& projString) {
- return Value{opts.serializeFieldName(projString)};
+ return Value{
+ opts.serializeFieldPathFromString(projString)};
});
return compFields;
}()});
diff --git a/src/mongo/db/pipeline/document_source_internal_unpack_bucket_test/unpack_bucket_exec_test.cpp b/src/mongo/db/pipeline/document_source_internal_unpack_bucket_test/unpack_bucket_exec_test.cpp
index 3dd4d527acc..8ca1f6ec75d 100644
--- a/src/mongo/db/pipeline/document_source_internal_unpack_bucket_test/unpack_bucket_exec_test.cpp
+++ b/src/mongo/db/pipeline/document_source_internal_unpack_bucket_test/unpack_bucket_exec_test.cpp
@@ -936,8 +936,8 @@ TEST_F(InternalUnpackBucketExecTest, RedactsCorrectly) {
"bucketMaxSpanSeconds: 3600, computedMetaProjFields: ['a', 'b', 'c']}}");
auto array = std::vector<Value>{};
SerializationOptions opts;
- opts.redactFieldNamesStrategy = redactFieldNameForTest;
- opts.redactFieldNames = true;
+ opts.identifierRedactionPolicy = redactFieldNameForTest;
+ opts.redactIdentifiers = true;
opts.replacementForLiteralArgs = "?";
DocumentSourceInternalUnpackBucket::createFromBsonInternal(bson.firstElement(), getExpCtx())
->serializeToArray(array, opts);
diff --git a/src/mongo/db/pipeline/document_source_list_cached_and_active_users.h b/src/mongo/db/pipeline/document_source_list_cached_and_active_users.h
index a9a31707a77..d86611ac874 100644
--- a/src/mongo/db/pipeline/document_source_list_cached_and_active_users.h
+++ b/src/mongo/db/pipeline/document_source_list_cached_and_active_users.h
@@ -88,7 +88,7 @@ public:
}
Value serialize(SerializationOptions opts = SerializationOptions()) const final override {
- if (opts.redactFieldNames || opts.replacementForLiteralArgs) {
+ if (opts.redactIdentifiers || opts.replacementForLiteralArgs) {
MONGO_UNIMPLEMENTED_TASSERT(7484330);
}
return Value(Document{{getSourceName(), Document{}}});
diff --git a/src/mongo/db/pipeline/document_source_list_local_sessions.h b/src/mongo/db/pipeline/document_source_list_local_sessions.h
index d3c8c47d127..1244c2fa0ff 100644
--- a/src/mongo/db/pipeline/document_source_list_local_sessions.h
+++ b/src/mongo/db/pipeline/document_source_list_local_sessions.h
@@ -102,7 +102,7 @@ public:
}
Value serialize(SerializationOptions opts = SerializationOptions()) const final override {
- if (opts.redactFieldNames || opts.replacementForLiteralArgs) {
+ if (opts.redactIdentifiers || opts.replacementForLiteralArgs) {
MONGO_UNIMPLEMENTED_TASSERT(7484328);
}
return Value(Document{{getSourceName(), _spec.toBSON()}});
diff --git a/src/mongo/db/pipeline/document_source_list_sessions.cpp b/src/mongo/db/pipeline/document_source_list_sessions.cpp
index e1f2ea650a3..2370d5d324a 100644
--- a/src/mongo/db/pipeline/document_source_list_sessions.cpp
+++ b/src/mongo/db/pipeline/document_source_list_sessions.cpp
@@ -75,7 +75,7 @@ boost::intrusive_ptr<DocumentSource> DocumentSourceListSessions::createFromBson(
}
Value DocumentSourceListSessions::serialize(SerializationOptions opts) const {
- if (opts.redactFieldNames || opts.replacementForLiteralArgs) {
+ if (opts.redactIdentifiers || opts.replacementForLiteralArgs) {
MONGO_UNIMPLEMENTED_TASSERT(7484327);
}
ListSessionsSpec spec;
diff --git a/src/mongo/db/pipeline/document_source_lookup.cpp b/src/mongo/db/pipeline/document_source_lookup.cpp
index 976ce9c78e5..ef96a3a83ec 100644
--- a/src/mongo/db/pipeline/document_source_lookup.cpp
+++ b/src/mongo/db/pipeline/document_source_lookup.cpp
@@ -1024,7 +1024,7 @@ void DocumentSourceLookUp::appendSpecificExecStats(MutableDocument& doc) const {
void DocumentSourceLookUp::serializeToArray(std::vector<Value>& array,
SerializationOptions opts) const {
auto explain = opts.verbosity;
- if (opts.redactFieldNames || opts.replacementForLiteralArgs) {
+ if (opts.redactIdentifiers || opts.replacementForLiteralArgs) {
MONGO_UNIMPLEMENTED_TASSERT(7484326);
}
diff --git a/src/mongo/db/pipeline/document_source_match.cpp b/src/mongo/db/pipeline/document_source_match.cpp
index 8e5bb956a0b..8856a1def3b 100644
--- a/src/mongo/db/pipeline/document_source_match.cpp
+++ b/src/mongo/db/pipeline/document_source_match.cpp
@@ -69,7 +69,7 @@ const char* DocumentSourceMatch::getSourceName() const {
}
Value DocumentSourceMatch::serialize(SerializationOptions opts) const {
- if (opts.verbosity || opts.redactFieldNames || opts.replacementForLiteralArgs) {
+ if (opts.verbosity || opts.redactIdentifiers || opts.replacementForLiteralArgs) {
return Value(DOC(getSourceName() << Document(_expression->serialize(opts))));
}
return Value(DOC(getSourceName() << Document(getQuery())));
diff --git a/src/mongo/db/pipeline/document_source_match_test.cpp b/src/mongo/db/pipeline/document_source_match_test.cpp
index 718a2a565f6..e699537521d 100644
--- a/src/mongo/db/pipeline/document_source_match_test.cpp
+++ b/src/mongo/db/pipeline/document_source_match_test.cpp
@@ -708,10 +708,10 @@ TEST_F(DocumentSourceMatchTest, RedactionWithAnd) {
$match: {
$and: [
{
- a: 'abc'
+ "a.c": "abc"
},
{
- b: {
+ "b": {
$gt: 10
}
}
@@ -723,7 +723,7 @@ TEST_F(DocumentSourceMatchTest, RedactionWithAnd) {
"$match": {
"$and": [
{
- "HASH<a>": {
+ "HASH<a>.HASH<c>": {
"$eq": "?"
}
},
diff --git a/src/mongo/db/pipeline/document_source_merge.cpp b/src/mongo/db/pipeline/document_source_merge.cpp
index 00b033a5b34..d21c8392324 100644
--- a/src/mongo/db/pipeline/document_source_merge.cpp
+++ b/src/mongo/db/pipeline/document_source_merge.cpp
@@ -534,7 +534,7 @@ boost::optional<DocumentSource::DistributedPlanLogic> DocumentSourceMerge::distr
Value DocumentSourceMerge::serialize(SerializationOptions opts) const {
auto explain = opts.verbosity;
- if (opts.redactFieldNames || opts.replacementForLiteralArgs) {
+ if (opts.redactIdentifiers || opts.replacementForLiteralArgs) {
MONGO_UNIMPLEMENTED_TASSERT(7484324);
}
diff --git a/src/mongo/db/pipeline/document_source_out.cpp b/src/mongo/db/pipeline/document_source_out.cpp
index 772e3c95ed3..113ce0b77cb 100644
--- a/src/mongo/db/pipeline/document_source_out.cpp
+++ b/src/mongo/db/pipeline/document_source_out.cpp
@@ -214,8 +214,8 @@ boost::intrusive_ptr<DocumentSource> DocumentSourceOut::createFromBson(
Value DocumentSourceOut::serialize(SerializationOptions opts) const {
MutableDocument spec;
// Do not include the tenantId in the serialized 'outputNs'.
- spec["db"] = Value(opts.serializeFieldName(_outputNs.dbName().db()));
- spec["coll"] = Value(opts.serializeFieldName(_outputNs.coll()));
+ spec["db"] = Value(opts.serializeIdentifier(_outputNs.dbName().db()));
+ spec["coll"] = Value(opts.serializeIdentifier(_outputNs.coll()));
return Value(Document{{kStageName, spec.freezeToValue()}});
}
diff --git a/src/mongo/db/pipeline/document_source_plan_cache_stats.cpp b/src/mongo/db/pipeline/document_source_plan_cache_stats.cpp
index 80d16e01d72..ddfcae2457e 100644
--- a/src/mongo/db/pipeline/document_source_plan_cache_stats.cpp
+++ b/src/mongo/db/pipeline/document_source_plan_cache_stats.cpp
@@ -62,7 +62,7 @@ void DocumentSourcePlanCacheStats::serializeToArray(std::vector<Value>& array,
if (opts.verbosity) {
tassert(7513100,
"$planCacheStats is not equipped to serialize in explain mode with redaction on",
- !opts.redactFieldNames && !opts.replacementForLiteralArgs);
+ !opts.redactIdentifiers && !opts.replacementForLiteralArgs);
array.push_back(Value{
Document{{kStageName,
Document{{"match"_sd,
diff --git a/src/mongo/db/pipeline/document_source_plan_cache_stats_test.cpp b/src/mongo/db/pipeline/document_source_plan_cache_stats_test.cpp
index 126c3e90374..1c803c311d6 100644
--- a/src/mongo/db/pipeline/document_source_plan_cache_stats_test.cpp
+++ b/src/mongo/db/pipeline/document_source_plan_cache_stats_test.cpp
@@ -155,10 +155,10 @@ TEST_F(DocumentSourcePlanCacheStatsTest, RedactsSuccessfullyAfterAbsorbingMatch)
SerializationOptions options;
options.replacementForLiteralArgs = "?";
- options.redactFieldNamesStrategy = [](StringData s) -> std::string {
+ options.identifierRedactionPolicy = [](StringData s) -> std::string {
return str::stream() << "HASH<" << s << ">";
};
- options.redactFieldNames = true;
+ options.redactIdentifiers = true;
pipeline->optimizePipeline();
ASSERT_EQ(1u, pipeline->getSources().size());
diff --git a/src/mongo/db/pipeline/document_source_queue.cpp b/src/mongo/db/pipeline/document_source_queue.cpp
index 3d3019188c1..7014a159842 100644
--- a/src/mongo/db/pipeline/document_source_queue.cpp
+++ b/src/mongo/db/pipeline/document_source_queue.cpp
@@ -81,7 +81,7 @@ DocumentSource::GetNextResult DocumentSourceQueue::doGetNext() {
}
Value DocumentSourceQueue::serialize(SerializationOptions opts) const {
- if (opts.redactFieldNames || opts.replacementForLiteralArgs) {
+ if (opts.redactIdentifiers || opts.replacementForLiteralArgs) {
MONGO_UNIMPLEMENTED_TASSERT(7484319);
}
diff --git a/src/mongo/db/pipeline/document_source_sequential_document_cache.cpp b/src/mongo/db/pipeline/document_source_sequential_document_cache.cpp
index 5fd98a6d381..5cd3563cfe8 100644
--- a/src/mongo/db/pipeline/document_source_sequential_document_cache.cpp
+++ b/src/mongo/db/pipeline/document_source_sequential_document_cache.cpp
@@ -156,7 +156,7 @@ Pipeline::SourceContainer::iterator DocumentSourceSequentialDocumentCache::doOpt
}
Value DocumentSourceSequentialDocumentCache::serialize(SerializationOptions opts) const {
- if (opts.redactFieldNames || opts.replacementForLiteralArgs) {
+ if (opts.redactIdentifiers || opts.replacementForLiteralArgs) {
MONGO_UNIMPLEMENTED_TASSERT(7484315);
}
if (opts.verbosity) {
diff --git a/src/mongo/db/pipeline/document_source_set_variable_from_subpipeline.cpp b/src/mongo/db/pipeline/document_source_set_variable_from_subpipeline.cpp
index 010e4685a8a..bb5ccb6bf93 100644
--- a/src/mongo/db/pipeline/document_source_set_variable_from_subpipeline.cpp
+++ b/src/mongo/db/pipeline/document_source_set_variable_from_subpipeline.cpp
@@ -54,7 +54,7 @@ REGISTER_INTERNAL_DOCUMENT_SOURCE(setVariableFromSubPipeline,
true);
Value DocumentSourceSetVariableFromSubPipeline::serialize(SerializationOptions opts) const {
- if (opts.redactFieldNames || opts.replacementForLiteralArgs) {
+ if (opts.redactIdentifiers || opts.replacementForLiteralArgs) {
MONGO_UNIMPLEMENTED_TASSERT(7484314);
}
diff --git a/src/mongo/db/pipeline/document_source_set_window_fields.cpp b/src/mongo/db/pipeline/document_source_set_window_fields.cpp
index 1b31e29d707..c06e89155c5 100644
--- a/src/mongo/db/pipeline/document_source_set_window_fields.cpp
+++ b/src/mongo/db/pipeline/document_source_set_window_fields.cpp
@@ -140,7 +140,7 @@ WindowFunctionStatement WindowFunctionStatement::parse(BSONElement elem,
}
void WindowFunctionStatement::serialize(MutableDocument& outputFields,
SerializationOptions opts) const {
- outputFields[opts.serializeFieldName(fieldName)] = expr->serialize(opts);
+ outputFields[opts.serializeFieldPathFromString(fieldName)] = expr->serialize(opts);
}
list<intrusive_ptr<DocumentSource>> document_source_set_window_fields::create(
@@ -307,7 +307,7 @@ Value DocumentSourceInternalSetWindowFields::serialize(SerializationOptions opts
MutableDocument md;
for (auto&& [fieldName, function] : _executableOutputs) {
- md[opts.serializeFieldName(fieldName)] = opts.serializeLiteralValue(
+ md[opts.serializeFieldPathFromString(fieldName)] = opts.serializeLiteralValue(
static_cast<long long>(_memoryTracker[fieldName].maxMemoryBytes()));
}
diff --git a/src/mongo/db/pipeline/document_source_set_window_fields_test.cpp b/src/mongo/db/pipeline/document_source_set_window_fields_test.cpp
index 4e0dfbcc189..e6705d64e01 100644
--- a/src/mongo/db/pipeline/document_source_set_window_fields_test.cpp
+++ b/src/mongo/db/pipeline/document_source_set_window_fields_test.cpp
@@ -260,7 +260,7 @@ TEST_F(DocumentSourceSetWindowFieldsTest, RedactionOnExpMovingAvgOperator) {
auto spec = fromjson(
R"({
$setWindowFields: {
- partitionBy: '$foo',
+ partitionBy: '$foo.bar',
sortBy: {
bar: 1
},
@@ -280,7 +280,7 @@ TEST_F(DocumentSourceSetWindowFieldsTest, RedactionOnExpMovingAvgOperator) {
ASSERT_BSONOBJ_EQ_AUTO( // NOLINT
R"({
"$_internalSetWindowFields": {
- "partitionBy": "$HASH<foo>",
+ "partitionBy": "$HASH<foo>.HASH<bar>",
"sortBy": {
"HASH<bar>": 1
},
diff --git a/src/mongo/db/pipeline/document_source_single_document_transformation.cpp b/src/mongo/db/pipeline/document_source_single_document_transformation.cpp
index 109e0883b52..6604fff1784 100644
--- a/src/mongo/db/pipeline/document_source_single_document_transformation.cpp
+++ b/src/mongo/db/pipeline/document_source_single_document_transformation.cpp
@@ -88,7 +88,7 @@ void DocumentSourceSingleDocumentTransformation::doDispose() {
}
Value DocumentSourceSingleDocumentTransformation::serialize(SerializationOptions opts) const {
- if (opts.redactFieldNames || opts.replacementForLiteralArgs) {
+ if (opts.redactIdentifiers || opts.replacementForLiteralArgs) {
MONGO_UNIMPLEMENTED_TASSERT(7484312);
}
diff --git a/src/mongo/db/pipeline/document_source_skip.cpp b/src/mongo/db/pipeline/document_source_skip.cpp
index 6eda5a592f5..2d05d6695a7 100644
--- a/src/mongo/db/pipeline/document_source_skip.cpp
+++ b/src/mongo/db/pipeline/document_source_skip.cpp
@@ -73,7 +73,7 @@ DocumentSource::GetNextResult DocumentSourceSkip::doGetNext() {
}
Value DocumentSourceSkip::serialize(SerializationOptions opts) const {
- if (opts.redactFieldNames || opts.replacementForLiteralArgs) {
+ if (opts.redactIdentifiers || opts.replacementForLiteralArgs) {
MONGO_UNIMPLEMENTED_TASSERT(7484311);
}
diff --git a/src/mongo/db/pipeline/document_source_sort.cpp b/src/mongo/db/pipeline/document_source_sort.cpp
index bc6d90b7386..7c313743662 100644
--- a/src/mongo/db/pipeline/document_source_sort.cpp
+++ b/src/mongo/db/pipeline/document_source_sort.cpp
@@ -284,7 +284,7 @@ boost::intrusive_ptr<DocumentSource> DocumentSourceSort::clone(
void DocumentSourceSort::serializeToArray(std::vector<Value>& array,
SerializationOptions opts) const {
auto explain = opts.verbosity;
- if (opts.redactFieldNames || opts.replacementForLiteralArgs) {
+ if (opts.redactIdentifiers || opts.replacementForLiteralArgs) {
MONGO_UNIMPLEMENTED_TASSERT(7484310);
}
diff --git a/src/mongo/db/pipeline/document_source_streaming_group.cpp b/src/mongo/db/pipeline/document_source_streaming_group.cpp
index 7a019b55f95..4b6dea86d22 100644
--- a/src/mongo/db/pipeline/document_source_streaming_group.cpp
+++ b/src/mongo/db/pipeline/document_source_streaming_group.cpp
@@ -157,10 +157,10 @@ void DocumentSourceStreamingGroup::serializeAdditionalFields(MutableDocument& ou
SerializationOptions opts) const {
std::vector<Value> monotonicIdFields;
if (_idFieldNames.empty()) {
- monotonicIdFields.emplace_back(opts.serializeFieldName("_id"));
+ monotonicIdFields.emplace_back(opts.serializeFieldPath("_id"));
} else {
for (size_t i : _monotonicExpressionIndexes) {
- monotonicIdFields.emplace_back(opts.serializeFieldName(_idFieldNames[i]));
+ monotonicIdFields.emplace_back(opts.serializeFieldPathFromString(_idFieldNames[i]));
}
}
out[kMonotonicIdFieldsSpecField] = Value(std::move(monotonicIdFields));
diff --git a/src/mongo/db/pipeline/document_source_telemetry.cpp b/src/mongo/db/pipeline/document_source_telemetry.cpp
index f226c53982c..4d81065855f 100644
--- a/src/mongo/db/pipeline/document_source_telemetry.cpp
+++ b/src/mongo/db/pipeline/document_source_telemetry.cpp
@@ -49,23 +49,23 @@ bool parseTelemetryEmbeddedObject(BSONObj embeddedObj) {
uassert(ErrorCodes::FailedToParse,
str::stream()
<< DocumentSourceTelemetry::kStageName
- << " parameters object may only contain one field, 'redactFieldNames'. Found: "
+ << " parameters object may only contain one field, 'redactIdentifiers'. Found: "
<< embeddedObj.toString(),
embeddedObj.nFields() == 1);
uassert(ErrorCodes::FailedToParse,
str::stream()
<< DocumentSourceTelemetry::kStageName
- << " parameters object may only contain 'redactFieldNames' option. Found: "
+ << " parameters object may only contain 'redactIdentifiers' option. Found: "
<< embeddedObj.firstElementFieldName(),
- embeddedObj.hasField("redactFieldNames"));
+ embeddedObj.hasField("redactIdentifiers"));
uassert(ErrorCodes::FailedToParse,
str::stream() << DocumentSourceTelemetry::kStageName
- << " redactFieldNames parameter must be boolean. Found type: "
+ << " redactIdentifiers parameter must be boolean. Found type: "
<< typeName(embeddedObj.firstElementType()),
embeddedObj.firstElementType() == BSONType::Bool);
- fieldNameRedaction = embeddedObj["redactFieldNames"].trueValue();
+ fieldNameRedaction = embeddedObj["redactIdentifiers"].trueValue();
}
return fieldNameRedaction;
}
@@ -144,7 +144,7 @@ DocumentSource::GetNextResult DocumentSourceTelemetry::doGetNext() {
const auto partitionReadTime =
Timestamp{Timestamp(Date_t::now().toMillisSinceEpoch() / 1000, 0)};
for (auto&& [key, metrics] : *partition) {
- auto swKey = metrics->redactKey(key, _redactFieldNames, pExpCtx->opCtx);
+ auto swKey = metrics->redactKey(key, _redactIdentifiers, pExpCtx->opCtx);
if (!swKey.isOK()) {
LOGV2_DEBUG(7349403,
3,
diff --git a/src/mongo/db/pipeline/document_source_telemetry.h b/src/mongo/db/pipeline/document_source_telemetry.h
index befd91851de..fff298025f0 100644
--- a/src/mongo/db/pipeline/document_source_telemetry.h
+++ b/src/mongo/db/pipeline/document_source_telemetry.h
@@ -47,9 +47,9 @@ public:
static std::unique_ptr<LiteParsed> parse(const NamespaceString& nss,
const BSONElement& spec);
- LiteParsed(std::string parseTimeName, bool redactFieldNames)
+ LiteParsed(std::string parseTimeName, bool redactIdentifiers)
: LiteParsedDocumentSource(std::move(parseTimeName)),
- _redactFieldNames(redactFieldNames) {}
+ _redactIdentifiers(redactIdentifiers) {}
stdx::unordered_set<NamespaceString> getInvolvedNamespaces() const override {
return stdx::unordered_set<NamespaceString>();
@@ -74,7 +74,7 @@ public:
transactionNotSupported(kStageName);
}
- bool _redactFieldNames;
+ bool _redactIdentifiers;
};
static boost::intrusive_ptr<DocumentSource> createFromBson(
@@ -112,8 +112,8 @@ public:
private:
DocumentSourceTelemetry(const boost::intrusive_ptr<ExpressionContext>& expCtx,
- bool redactFieldNames = false)
- : DocumentSource(kStageName, expCtx), _redactFieldNames(redactFieldNames) {}
+ bool redactIdentifiers = false)
+ : DocumentSource(kStageName, expCtx), _redactIdentifiers(redactIdentifiers) {}
GetNextResult doGetNext() final;
@@ -130,7 +130,7 @@ private:
TelemetryStore::PartitionId _currentPartition = -1;
// When true, redact field names from returned query shapes.
- bool _redactFieldNames;
+ bool _redactIdentifiers;
};
} // namespace mongo
diff --git a/src/mongo/db/pipeline/document_source_union_with.cpp b/src/mongo/db/pipeline/document_source_union_with.cpp
index 3506561f46a..fd745b37e0c 100644
--- a/src/mongo/db/pipeline/document_source_union_with.cpp
+++ b/src/mongo/db/pipeline/document_source_union_with.cpp
@@ -328,7 +328,7 @@ void DocumentSourceUnionWith::doDispose() {
Value DocumentSourceUnionWith::serialize(SerializationOptions opts) const {
auto explain = opts.verbosity;
- if (opts.redactFieldNames || opts.replacementForLiteralArgs) {
+ if (opts.redactIdentifiers || opts.replacementForLiteralArgs) {
MONGO_UNIMPLEMENTED_TASSERT(7484307);
}
diff --git a/src/mongo/db/pipeline/document_source_unwind.cpp b/src/mongo/db/pipeline/document_source_unwind.cpp
index 8e3e6c4a602..b5ae2df4865 100644
--- a/src/mongo/db/pipeline/document_source_unwind.cpp
+++ b/src/mongo/db/pipeline/document_source_unwind.cpp
@@ -296,10 +296,10 @@ Pipeline::SourceContainer::iterator DocumentSourceUnwind::doOptimizeAt(
Value DocumentSourceUnwind::serialize(SerializationOptions opts) const {
return Value(DOC(
getSourceName() << DOC(
- "path" << _unwindPath.redactedFullPathWithPrefix(opts) << "preserveNullAndEmptyArrays"
+ "path" << opts.serializeFieldPathWithPrefix(_unwindPath) << "preserveNullAndEmptyArrays"
<< (_preserveNullAndEmptyArrays ? opts.serializeLiteralValue(true) : Value())
<< "includeArrayIndex"
- << (_indexPath ? Value((*_indexPath).redactedFullPath(opts)) : Value()))));
+ << (_indexPath ? Value(opts.serializeFieldPath(*_indexPath)) : Value()))));
}
DepsTracker::State DocumentSourceUnwind::getDependencies(DepsTracker* deps) const {
diff --git a/src/mongo/db/pipeline/expression.cpp b/src/mongo/db/pipeline/expression.cpp
index c239ab05d1e..7800bdec863 100644
--- a/src/mongo/db/pipeline/expression.cpp
+++ b/src/mongo/db/pipeline/expression.cpp
@@ -2390,7 +2390,8 @@ Value ExpressionObject::serialize(SerializationOptions options) const {
}
MutableDocument outputDoc;
for (auto&& pair : _expressions) {
- outputDoc.addField(options.serializeFieldName(pair.first), pair.second->serialize(options));
+ outputDoc.addField(options.serializeFieldPathFromString(pair.first),
+ pair.second->serialize(options));
}
return outputDoc.freezeToValue();
}
@@ -2594,29 +2595,19 @@ auto getPrefixAndPath(FieldPath path) {
Value ExpressionFieldPath::serialize(SerializationOptions options) const {
auto [prefix, path] = getPrefixAndPath(_fieldPath);
- if (options.redactFieldNames) {
- // This is a variable.
- if (prefix.length() == 2) {
- if (path.getPathLength() == 1 && Variables::isBuiltin(_variable)) {
- // Nothing to redact.
- return Value(prefix + path.fullPath());
- } else if (path.getPathLength() == 1) {
- // This may be a variable or a field path, but either way it needs to be redacted.
- return Value(prefix + path.redactedFullPath(options));
- } else if (path.getPathLength() > 1 && Variables::isBuiltin(_variable)) {
- // The first component of this path is a system variable, so keep that and redact
- // the rest.
- return Value(prefix + path.front() + "." + path.tail().redactedFullPath(options));
- } else {
- // This path has multiple components, and each part is from the user. Redact every
- // component.
- return Value(prefix + path.redactedFullPath(options));
- }
+ // First handles special cases for redaction of system variables. User variables will fall
+ // through to the default full redaction case.
+ if (options.redactIdentifiers && prefix.length() == 2) {
+ if (path.getPathLength() == 1 && Variables::isBuiltin(_variable)) {
+ // Nothing to redact for builtin variables.
+ return Value(prefix + path.fullPath());
+ } else if (path.getPathLength() > 1 && Variables::isBuiltin(_variable)) {
+ // The first component of this path is a system variable, so keep that and redact
+ // the rest.
+ return Value(prefix + path.front() + "." + options.serializeFieldPath(path.tail()));
}
- return Value(path.redactedFullPathWithPrefix(options));
- } else {
- return Value(prefix + path.fullPath());
}
+ return Value(prefix + options.serializeFieldPath(path));
}
Expression::ComputedPaths ExpressionFieldPath::getComputedPaths(const std::string& exprFieldPath,
@@ -2954,8 +2945,8 @@ Value ExpressionLet::serialize(SerializationOptions options) const {
for (VariableMap::const_iterator it = _variables.begin(), end = _variables.end(); it != end;
++it) {
auto key = it->second.name;
- if (options.redactFieldNames) {
- key = options.redactFieldNamesStrategy(key);
+ if (options.redactIdentifiers) {
+ key = options.identifierRedactionPolicy(key);
}
vars[key] = it->second.expression->serialize(options);
}
@@ -8138,13 +8129,12 @@ intrusive_ptr<Expression> ExpressionGetField::optimize() {
Value ExpressionGetField::serialize(SerializationOptions options) const {
MutableDocument argDoc;
- if (options.redactFieldNames) {
+ if (options.redactIdentifiers) {
// The parser guarantees that the '_children[_kField]' expression evaluates to a constant
// string.
auto strPath =
static_cast<ExpressionConstant*>(_children[_kField].get())->getValue().getString();
- FieldPath fp(strPath);
- argDoc.addField("field"_sd, Value(fp.redactedFullPath(options)));
+ argDoc.addField("field"_sd, Value(options.serializeFieldPathFromString(strPath)));
} else {
argDoc.addField("field"_sd, _children[_kField]->serialize(options));
}
@@ -8262,13 +8252,12 @@ intrusive_ptr<Expression> ExpressionSetField::optimize() {
Value ExpressionSetField::serialize(SerializationOptions options) const {
MutableDocument argDoc;
- if (options.redactFieldNames) {
+ if (options.redactIdentifiers) {
// The parser guarantees that the '_children[_kField]' expression evaluates to a constant
// string.
auto strPath =
static_cast<ExpressionConstant*>(_children[_kField].get())->getValue().getString();
- FieldPath fp(strPath);
- argDoc.addField("field"_sd, Value(fp.redactedFullPath(options)));
+ argDoc.addField("field"_sd, Value(options.serializeFieldPathFromString(strPath)));
} else {
argDoc.addField("field"_sd, _children[_kField]->serialize(options));
}
diff --git a/src/mongo/db/pipeline/expression_field_path_test.cpp b/src/mongo/db/pipeline/expression_field_path_test.cpp
index 4fba45c34a2..4b332d9e4f4 100644
--- a/src/mongo/db/pipeline/expression_field_path_test.cpp
+++ b/src/mongo/db/pipeline/expression_field_path_test.cpp
@@ -233,8 +233,8 @@ TEST(FieldPath, ScalarVariableWithDottedFieldPathOptimizesToConstantMissingValue
TEST(FieldPath, SerializeWithRedaction) {
SerializationOptions options;
- options.redactFieldNamesStrategy = redactFieldNameForTest;
- options.redactFieldNames = true;
+ options.identifierRedactionPolicy = redactFieldNameForTest;
+ options.redactIdentifiers = true;
auto expCtx = ExpressionContextForTest{};
intrusive_ptr<Expression> expression =
diff --git a/src/mongo/db/pipeline/expression_function_test.cpp b/src/mongo/db/pipeline/expression_function_test.cpp
index d5bd70397b8..640804b55b4 100644
--- a/src/mongo/db/pipeline/expression_function_test.cpp
+++ b/src/mongo/db/pipeline/expression_function_test.cpp
@@ -50,8 +50,8 @@ TEST(ExpressionFunction, SerializeAndRedactArgs) {
SerializationOptions options;
std::string replacementChar = "?";
options.replacementForLiteralArgs = replacementChar;
- options.redactFieldNames = true;
- options.redactFieldNamesStrategy = redactFieldNameForTest;
+ options.redactIdentifiers = true;
+ options.identifierRedactionPolicy = redactFieldNameForTest;
auto expCtx = ExpressionContextForTest();
auto expr = BSON("$function" << BSON("body"
diff --git a/src/mongo/db/pipeline/expression_let_test.cpp b/src/mongo/db/pipeline/expression_let_test.cpp
index 75d6ee09ac0..fe4e1291fc5 100644
--- a/src/mongo/db/pipeline/expression_let_test.cpp
+++ b/src/mongo/db/pipeline/expression_let_test.cpp
@@ -44,8 +44,8 @@ std::string redactFieldNameForTest(StringData s) {
TEST(RedactionTest, ExpressionLet) {
SerializationOptions options;
- options.redactFieldNamesStrategy = redactFieldNameForTest;
- options.redactFieldNames = true;
+ options.identifierRedactionPolicy = redactFieldNameForTest;
+ options.redactIdentifiers = true;
auto expCtx = ExpressionContextForTest{};
diff --git a/src/mongo/db/pipeline/expression_test.cpp b/src/mongo/db/pipeline/expression_test.cpp
index 04cc5c22ebf..ba1cf96b27c 100644
--- a/src/mongo/db/pipeline/expression_test.cpp
+++ b/src/mongo/db/pipeline/expression_test.cpp
@@ -3731,8 +3731,8 @@ TEST(ExpressionGetFieldTest, GetFieldSerializesAndRedactsCorrectly) {
SerializationOptions options;
std::string replacementChar = "?";
options.replacementForLiteralArgs = replacementChar;
- options.redactFieldNamesStrategy = redactFieldNameForTest;
- options.redactFieldNames = true;
+ options.identifierRedactionPolicy = redactFieldNameForTest;
+ options.redactIdentifiers = true;
auto expCtx = ExpressionContextForTest{};
VariablesParseState vps = expCtx.variablesParseState;
@@ -3776,8 +3776,8 @@ TEST(ExpressionSetFieldTest, SetFieldRedactsCorrectly) {
SerializationOptions options;
std::string replacementChar = "?";
options.replacementForLiteralArgs = replacementChar;
- options.redactFieldNamesStrategy = redactFieldNameForTest;
- options.redactFieldNames = true;
+ options.identifierRedactionPolicy = redactFieldNameForTest;
+ options.redactIdentifiers = true;
auto expCtx = ExpressionContextForTest{};
VariablesParseState vps = expCtx.variablesParseState;
diff --git a/src/mongo/db/pipeline/field_path.cpp b/src/mongo/db/pipeline/field_path.cpp
index 7f2fb3cd5ea..9a0a53f61fc 100644
--- a/src/mongo/db/pipeline/field_path.cpp
+++ b/src/mongo/db/pipeline/field_path.cpp
@@ -164,18 +164,4 @@ FieldPath FieldPath::concat(const FieldPath& tail) const {
return FieldPath(std::move(concat), std::move(newDots), std::move(newHashes));
}
-
-std::string FieldPath::redactedFullPath(SerializationOptions opts) const {
- if (!opts.redactFieldNames) {
- return fullPath();
- }
- std::stringstream redacted;
- for (size_t i = 0; i < getPathLength(); ++i) {
- if (i > 0) {
- redacted << ".";
- }
- redacted << opts.redactFieldNamesStrategy(getFieldName(i));
- }
- return redacted.str();
-}
} // namespace mongo
diff --git a/src/mongo/db/pipeline/field_path.h b/src/mongo/db/pipeline/field_path.h
index e185a7d7601..60792a5e2d2 100644
--- a/src/mongo/db/pipeline/field_path.h
+++ b/src/mongo/db/pipeline/field_path.h
@@ -36,7 +36,6 @@
#include "mongo/base/string_data.h"
#include "mongo/bson/bson_depth.h"
#include "mongo/db/exec/document_value/document_internal.h"
-#include "mongo/db/query/serialization_options.h"
#include "mongo/util/assert_util.h"
namespace mongo {
@@ -130,7 +129,6 @@ public:
const std::string& fullPath() const {
return _fieldPath;
}
- std::string redactedFullPath(SerializationOptions opts) const;
/**
* Returns the full path, including the prefix 'FieldPath::prefix'.
@@ -138,9 +136,6 @@ public:
std::string fullPathWithPrefix() const {
return prefix + _fieldPath;
}
- std::string redactedFullPathWithPrefix(SerializationOptions opts) const {
- return prefix + redactedFullPath(opts);
- }
/**
* A FieldPath like this but missing the first element (useful for recursion).