From f2a0b3ea4ca7ef0b0861a17ee1ed1770c4c8a0e3 Mon Sep 17 00:00:00 2001 From: James Wyatt Cready-Pyle Date: Fri, 11 Nov 2022 13:43:46 -0500 Subject: [PATCH] Avoid overwriting a set oneof field in target with an unset oneof field in source Fixes: #386 --- packages/runtime/src/reflection-merge-partial.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/runtime/src/reflection-merge-partial.ts b/packages/runtime/src/reflection-merge-partial.ts index 6a69469a..d5cbccf5 100644 --- a/packages/runtime/src/reflection-merge-partial.ts +++ b/packages/runtime/src/reflection-merge-partial.ts @@ -37,7 +37,7 @@ export function reflectionMergePartial(info: MessageInfo, targ if (field.oneof) { const group = input[field.oneof] as UnknownOneofGroup | undefined; // this is the oneof`s group in the source - if (group == undefined) { // the user is free to omit + if (group?.oneofKind == undefined) { // the user is free to omit continue; // we skip this field, and all other members too } fieldValue = group[name]; // our value comes from the the oneof group of the source