DBZ-987 Allow to processes full document updates
This commit is contained in:
parent
c540391db2
commit
b2aed1f46e
@ -143,10 +143,6 @@ public R apply(R r) {
|
||||
if (patchRecord.value() != null) {
|
||||
document = BsonDocument.parse(patchRecord.value().toString());
|
||||
|
||||
if (!document.containsKey("$set") && !document.containsKey("$unset")) {
|
||||
throw new ConnectException("Unable to process Mongo Operation, a '$set' or '$unset' is necessary.");
|
||||
}
|
||||
|
||||
valueDocument = new BsonDocument();
|
||||
|
||||
if (document.containsKey("$set")) {
|
||||
@ -166,6 +162,17 @@ public R apply(R r) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!document.containsKey("$set") && !document.containsKey("$unset")) {
|
||||
if (!document.containsKey("_id")) {
|
||||
throw new ConnectException("Unable to process Mongo Operation, a '$set' or '$unset' is necessary " +
|
||||
"for partial update or '_id' is expected for full Document replaces.");
|
||||
}
|
||||
// In case of a full update we can use the whole Document as it is
|
||||
// see https://docs.mongodb.com/manual/reference/method/db.collection.update/#replace-a-document-entirely
|
||||
valueDocument = document;
|
||||
valueDocument.remove("_id");
|
||||
}
|
||||
|
||||
if (!valueDocument.containsKey("id")) {
|
||||
valueDocument.append("id", keyDocument.get("id"));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user