Skip to content

Commit 508a5ec

Browse files
committed
JAVA-1152: For update command, only write multi or upsert field if the value is not the default.
1 parent 9abd39b commit 508a5ec

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/main/com/mongodb/UpdateCommandMessage.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,12 @@ protected UpdateCommandMessage writeTheWrites(final OutputBuffer buffer, final i
4646
writer.encodeDocument(getCommandEncoder(), update.getQuery());
4747
writer.writeName("u");
4848
writer.encodeDocument(encoder, update.getUpdateDocument());
49-
writer.writeBoolean("multi", update.isMulti());
50-
writer.writeBoolean("upsert", update.isUpsert());
49+
if (update.isMulti()) {
50+
writer.writeBoolean("multi", update.isMulti());
51+
}
52+
if (update.isUpsert()) {
53+
writer.writeBoolean("upsert", update.isUpsert());
54+
}
5155
writer.popMaxDocumentSize();
5256
writer.writeEndDocument();
5357
if (maximumCommandDocumentSizeExceeded(buffer, commandStartPosition)) {

0 commit comments

Comments
 (0)