Skip to content

Commit f211ccf

Browse files
committed
Review feedback
1 parent c5df0fd commit f211ccf

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

packages/firestore/src/api/user_data_reader.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -738,14 +738,15 @@ export function parseData(
738738
// context.fieldMask and we return null as our parsing result.
739739
parseSentinelFieldValue(input, context);
740740
return null;
741+
} else if (input === undefined && context.ignoreUndefinedProperties) {
742+
// If the input is undefined it can never participate in the fieldMask, so
743+
// don't handle this below. If `ignoreUndefinedProperties` is false,
744+
// `parseScalarValue` will reject an undefined value.
745+
return null;
741746
} else {
742747
// If context.path is null we are inside an array and we don't support
743748
// field mask paths more granular than the top-level array.
744-
//
745-
// If the input is undefined it can never participate in the fieldMask. With
746-
// `ignoreUndefinedProperties` set to false, `parseScalarValue` will reject
747-
// an undefined value.
748-
if (context.path && input !== undefined) {
749+
if (context.path) {
749750
context.fieldMask.push(context.path);
750751
}
751752

@@ -900,8 +901,6 @@ function parseScalarValue(
900901
value._key.path
901902
)
902903
};
903-
} else if (value === undefined && context.ignoreUndefinedProperties) {
904-
return null;
905904
} else {
906905
throw context.createError(
907906
`Unsupported field value: ${valueDescription(value)}`

packages/firestore/test/integration/api/fields.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,8 +400,8 @@ apiDescribe('`undefined` properties', (persistence: boolean) => {
400400

401401
it('are ignored in set({ merge: true })', () => {
402402
return withTestDocAndSettings(persistence, settings, async doc => {
403-
await doc.set({ foo: 'foo', 'bar': 'unchanged' });
404-
await doc.set({ foo: 'foo', 'bar': undefined }, { merge: true });
403+
await doc.set({ foo: 'foo', bar: 'unchanged' });
404+
await doc.set({ foo: 'foo', bar: undefined }, { merge: true });
405405
const docSnap = await doc.get();
406406
expect(docSnap.data()).to.deep.equal({ foo: 'foo', bar: 'unchanged' });
407407
});

0 commit comments

Comments
 (0)