Skip to content

Commit a9f6c3f

Browse files
authored
fix(firestore): respect ignoreUndefinedProperties in subpipelines (#8089)
1 parent a21356f commit a9f6c3f

2 files changed

Lines changed: 26 additions & 2 deletions

File tree

handwritten/firestore/dev/src/pipelines/expression.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10885,10 +10885,10 @@ class PipelineValueExpression extends Expression {
1088510885
/**
1088610886
* @internal
1088710887
*/
10888-
_validateUserData(_ignoreUndefinedProperties: boolean): void {
10888+
_validateUserData(ignoreUndefinedProperties: boolean): void {
1088910889
// Casting to bypass type checking becuase _validateUserData does not exist in the public types
1089010890
// eslint-disable-next-line @typescript-eslint/no-explicit-any
10891-
(this.pipeline as any)._validateUserData('PipelineValueExpression');
10891+
(this.pipeline as any)._validateUserData(ignoreUndefinedProperties);
1089210892
}
1089310893
}
1089410894

handwritten/firestore/dev/system-test/pipeline.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6216,6 +6216,30 @@ describe.skipClassic('Pipeline class', () => {
62166216
});
62176217
});
62186218

6219+
it('PipelineValueExpression respects ignoreUndefinedProperties', async () => {
6220+
const firestore_2 = getTestDb({ignoreUndefinedProperties: false});
6221+
6222+
const subWithUndefined = firestore_2
6223+
.pipeline()
6224+
.collection('test')
6225+
.where(equal(field('title'), {title: undefined}));
6226+
6227+
try {
6228+
await firestore_2
6229+
.pipeline()
6230+
.collection(randomCol.path)
6231+
.addFields(subWithUndefined.toArrayExpression().as('reviewsData'))
6232+
.execute();
6233+
6234+
expect(false).to.be.true('should have thrown an error');
6235+
} catch (e: unknown) {
6236+
const err: Error = e as Error;
6237+
expect(err.message).to.contain(
6238+
'Cannot use "undefined" as a Firestore value',
6239+
);
6240+
}
6241+
});
6242+
62196243
it('multiple array subqueries', async () => {
62206244
const reviewsCollectionName = `reviews_multi_${Date.now()}`;
62216245
const authorsCollectionName = `authors_multi_${Date.now()}`;

0 commit comments

Comments
 (0)