summaryrefslogtreecommitdiff
path: root/src/mongo/db
diff options
context:
space:
mode:
authorVesselina Ratcheva <vesselina.ratcheva@10gen.com>2020-08-10 22:56:50 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-08-10 23:11:03 +0000
commitf7663ec260985506ac482ddb86ceee100e64112d (patch)
treee757882988eee299244494976e719ec572178a53 /src/mongo/db
parent13eb3cca6547bb801d1cd01f95c8e9dd564dd47c (diff)
downloadmongo-f7663ec260985506ac482ddb86ceee100e64112d.tar.gz
Revert "SERVER-38909 Permit empty update modifiers, treating as a no-op rather than an error"
This reverts commit 957febbf065a51cc278c66c72f5a81ff2630201c.
Diffstat (limited to 'src/mongo/db')
-rw-r--r--src/mongo/db/update/update_driver.cpp7
-rw-r--r--src/mongo/db/update/update_driver_test.cpp7
2 files changed, 12 insertions, 2 deletions
diff --git a/src/mongo/db/update/update_driver.cpp b/src/mongo/db/update/update_driver.cpp
index 2e0754b3f92..e0cf8dafb4c 100644
--- a/src/mongo/db/update/update_driver.cpp
+++ b/src/mongo/db/update/update_driver.cpp
@@ -73,6 +73,13 @@ modifiertable::ModifierType validateMod(BSONElement mod) {
<< " not {" << mod << "}",
mod.type() == BSONType::Object);
+ uassert(ErrorCodes::FailedToParse,
+ str::stream() << "'" << mod.fieldName()
+ << "' is empty. You must specify a field like so: "
+ "{"
+ << mod.fieldName() << ": {<field>: ...}}",
+ !mod.embeddedObject().isEmpty());
+
return modType;
}
diff --git a/src/mongo/db/update/update_driver_test.cpp b/src/mongo/db/update/update_driver_test.cpp
index 743d3fbe67d..5c736122c65 100644
--- a/src/mongo/db/update/update_driver_test.cpp
+++ b/src/mongo/db/update/update_driver_test.cpp
@@ -121,8 +121,11 @@ TEST(Parse, EmptyMod) {
boost::intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());
UpdateDriver driver(expCtx);
std::map<StringData, std::unique_ptr<ExpressionWithPlaceholder>> arrayFilters;
- // Verifies that {$set: {}} is accepted.
- ASSERT_DOES_NOT_THROW(driver.parse(fromjson("{$set: {}}"), arrayFilters));
+ ASSERT_THROWS_CODE_AND_WHAT(
+ driver.parse(fromjson("{$set:{}}"), arrayFilters),
+ AssertionException,
+ ErrorCodes::FailedToParse,
+ "'$set' is empty. You must specify a field like so: {$set: {<field>: ...}}");
}
TEST(Parse, WrongMod) {