From 0d229dc933cfd74a5b5b06caf3f7779460fe282d Mon Sep 17 00:00:00 2001 From: James Wyatt Cready-Pyle Date: Tue, 15 Nov 2022 15:48:39 -0500 Subject: [PATCH] Avoid overwriting a set oneof field in target with an unset oneof field in source (#395) --- 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