summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mongo/db/field_ref_set.h5
-rw-r--r--src/mongo/db/ops/update_driver.cpp10
2 files changed, 11 insertions, 4 deletions
diff --git a/src/mongo/db/field_ref_set.h b/src/mongo/db/field_ref_set.h
index f84b14dc3db..5abd0ad9892 100644
--- a/src/mongo/db/field_ref_set.h
+++ b/src/mongo/db/field_ref_set.h
@@ -56,6 +56,11 @@ namespace mongo {
*/
bool insert(const FieldRef* toInsert, const FieldRef** conflict);
+ /** Returns 'true' if the set is empty */
+ bool empty() const {
+ return _fieldSet.empty();
+ }
+
private:
struct FieldRefPtrLessThan {
bool operator()(const FieldRef* lhs, const FieldRef* rhs) const;
diff --git a/src/mongo/db/ops/update_driver.cpp b/src/mongo/db/ops/update_driver.cpp
index 5332bd23730..b92bf310170 100644
--- a/src/mongo/db/ops/update_driver.cpp
+++ b/src/mongo/db/ops/update_driver.cpp
@@ -226,13 +226,15 @@ namespace mongo {
break;
}
- const FieldRef* other;
- if (!targetFields.insert(execInfo.fieldRef[i], &other)) {
- return Status(ErrorCodes::ConflictingUpdateOperators,
- mongoutils::str::stream()
+ if (!targetFields.empty() || _mods.size() > 1) {
+ const FieldRef* other;
+ if (!targetFields.insert(execInfo.fieldRef[i], &other)) {
+ return Status(ErrorCodes::ConflictingUpdateOperators,
+ mongoutils::str::stream()
<< "Cannot update '" << other->dottedField()
<< "' and '" << execInfo.fieldRef[i]->dottedField()
<< "' at the same time");
+ }
}
// We start with the expectation that a mod will be in-place. But if the mod