Skip to content

Commit de4b424

Browse files
committed
RUST-718 Enforce update versus replace semantics
1 parent 3b9852d commit de4b424

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/coll/mod.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -815,6 +815,7 @@ where
815815
session: impl Into<Option<&mut ClientSession>>,
816816
) -> Result<UpdateResult> {
817817
let replacement = to_document(&replacement)?;
818+
818819
bson_util::replacement_document_check(&replacement)?;
819820

820821
let mut options = options.into();
@@ -872,11 +873,12 @@ where
872873
session: impl Into<Option<&mut ClientSession>>,
873874
) -> Result<UpdateResult> {
874875
let update = update.into();
876+
875877
let mut options = options.into();
876878

877879
if let UpdateModifications::Document(ref d) = update {
878880
bson_util::update_document_check(d)?;
879-
};
881+
}
880882

881883
resolve_options!(self, options, [write_concern]);
882884

@@ -924,9 +926,15 @@ where
924926
session: impl Into<Option<&mut ClientSession>>,
925927
) -> Result<UpdateResult> {
926928
let mut options = options.into();
929+
let update = update.into();
930+
931+
if let UpdateModifications::Document(ref d) = update {
932+
bson_util::update_document_check(d)?;
933+
}
934+
927935
resolve_options!(self, options, [write_concern]);
928936

929-
let update = Update::new(self.namespace(), query, update.into(), false, options);
937+
let update = Update::new(self.namespace(), query, update, false, options);
930938
self.client().execute_operation(update, session).await
931939
}
932940

0 commit comments

Comments
 (0)