summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline/expression.cpp
diff options
context:
space:
mode:
authorYoonsoo Kim <yoonsoo.kim@mongodb.com>2023-05-13 03:30:00 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2023-05-13 05:01:45 +0000
commitcce813a0321b709fe846f4e0343e080a231f3a56 (patch)
treeae70884a03b0ebdcd32f4c1e3ff77ebd0dd04aed /src/mongo/db/pipeline/expression.cpp
parenta1f0cfdcbcc632133a7e65665c84b9344f4d8153 (diff)
downloadmongo-cce813a0321b709fe846f4e0343e080a231f3a56.tar.gz
SERVER-75853 Have hasOnlyRenameableMatchExpressionChildren() examine renames would succeed
Diffstat (limited to 'src/mongo/db/pipeline/expression.cpp')
-rw-r--r--src/mongo/db/pipeline/expression.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/mongo/db/pipeline/expression.cpp b/src/mongo/db/pipeline/expression.cpp
index 932c8404210..83fe6400e20 100644
--- a/src/mongo/db/pipeline/expression.cpp
+++ b/src/mongo/db/pipeline/expression.cpp
@@ -2649,6 +2649,21 @@ std::unique_ptr<Expression> ExpressionFieldPath::copyWithSubstitution(
return nullptr;
}
+bool ExpressionFieldPath::isRenameableByAnyPrefixNameIn(
+ const StringMap<std::string>& renameList) const {
+ if (_variable != Variables::kRootId || _fieldPath.getPathLength() == 1) {
+ return false;
+ }
+
+ FieldRef path(getFieldPathWithoutCurrentPrefix().fullPath());
+ for (const auto& rename : renameList) {
+ if (FieldRef oldName(rename.first); oldName.isPrefixOfOrEqualTo(path)) {
+ return true;
+ }
+ }
+ return false;
+}
+
monotonic::State ExpressionFieldPath::getMonotonicState(const FieldPath& sortedFieldPath) const {
return getFieldPathWithoutCurrentPrefix() == sortedFieldPath ? monotonic::State::Increasing
: monotonic::State::NonMonotonic;