Skip to content

Commit 5f88728

Browse files
committed
we should call ObjectValue.delete if value is null.
1 parent 39d0238 commit 5f88728

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

packages/firestore/src/model/mutation.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ export function calculateOverlayMutation(
242242
let maskSet = new SortedSet<FieldPath>(FieldPath.comparator);
243243
mask.fields.forEach(path => {
244244
if (!maskSet.has(path)) {
245-
const value = docValue.field(path);
245+
let value = docValue.field(path);
246246
// If we are deleting a nested field, we take the immediate parent as
247247
// the mask used to construct the resulting mutation.
248248
// Justification: Nested fields can create parent fields implicitly. If
@@ -254,8 +254,13 @@ export function calculateOverlayMutation(
254254
// mutation would miss `foo`.
255255
if (value === null && path.length > 1) {
256256
path = path.popLast();
257+
value = docValue.field(path);
258+
}
259+
if (value === null) {
260+
patchValue.delete(path);
261+
} else {
262+
patchValue.set(path, value);
257263
}
258-
patchValue.set(path, docValue.field(path)!);
259264
maskSet = maskSet.add(path);
260265
}
261266
});

0 commit comments

Comments
 (0)