summaryrefslogtreecommitdiff
path: root/src/mongo/db/update
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/update')
-rw-r--r--src/mongo/db/update/update_driver.cpp6
-rw-r--r--src/mongo/db/update/update_driver.h1
2 files changed, 6 insertions, 1 deletions
diff --git a/src/mongo/db/update/update_driver.cpp b/src/mongo/db/update/update_driver.cpp
index 7caaa4ab8a6..7ae41480779 100644
--- a/src/mongo/db/update/update_driver.cpp
+++ b/src/mongo/db/update/update_driver.cpp
@@ -166,7 +166,7 @@ Status UpdateDriver::parse(
clear();
// Check if the update expression is a full object replacement.
- if (*updateExpr.firstElementFieldName() != '$') {
+ if (isDocReplacement(updateExpr)) {
if (multi) {
return Status(ErrorCodes::FailedToParse, "multi update only works with $ operators");
}
@@ -581,4 +581,8 @@ void UpdateDriver::clear() {
_positional = false;
}
+bool UpdateDriver::isDocReplacement(const BSONObj& updateExpr) {
+ return *updateExpr.firstElementFieldName() != '$';
+}
+
} // namespace mongo
diff --git a/src/mongo/db/update/update_driver.h b/src/mongo/db/update/update_driver.h
index 337a1abfe87..e551d5fa2e8 100644
--- a/src/mongo/db/update/update_driver.h
+++ b/src/mongo/db/update/update_driver.h
@@ -126,6 +126,7 @@ public:
size_t numMods() const;
bool isDocReplacement() const;
+ static bool isDocReplacement(const BSONObj& updateExpr);
bool modsAffectIndices() const;
void refreshIndexKeys(const UpdateIndexData* indexedFields);