From 3f3949ce17684fbb6fcb2b62c2d2fcde13bc7f2c Mon Sep 17 00:00:00 2001 From: "nima.taheri@hootsuite.com" Date: Wed, 13 Mar 2024 22:15:52 -0700 Subject: [PATCH] feat: use full document replace when available instead of $set otherwise the update will be attempted per individual fields which is both incorrect and will fail because _id can to be set --- oplog/changestram_event.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/oplog/changestram_event.go b/oplog/changestram_event.go index d89e3da5..3950951d 100644 --- a/oplog/changestram_event.go +++ b/oplog/changestram_event.go @@ -220,7 +220,7 @@ func ConvertEvent2Oplog(input []byte, fulldoc bool) (*PartialLog, error) { oplog.Namespace = fmt.Sprintf("%s.%s", ns["db"], ns["coll"]) oplog.Operation = "u" oplog.Query = event.DocumentKey - oplog.Object = bson.D{{"$set", event.FullDocument}} + oplog.Object = event.FullDocument case "update": /* * mgset-xxx:PRIMARY> db.test.find() @@ -280,7 +280,7 @@ func ConvertEvent2Oplog(input []byte, fulldoc bool) (*PartialLog, error) { oplog.Query = event.DocumentKey if fulldoc && event.FullDocument != nil && len(event.FullDocument) > 0 { - oplog.Object = bson.D{{"$set", event.FullDocument}} + oplog.Object = event.FullDocument } else { oplog.Object = make(bson.D, 0, 2) if updatedFields, ok := event.UpdateDescription["updatedFields"]; ok && len(updatedFields.(bson.M)) > 0 {