GeezerVison is showing github.com — fix(firestore): respect `ignoreUndefinedProperties` in subpipelines (… · googleapis/google-cloud-node@a9f6c3f
File tree
Expand file treeCollapse file tree
Open diff view settings
handwritten/firestore/dev
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: handwritten/firestore/dev/src/pipelines/expression.ts +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -10885,10 +10885,10 @@ class PipelineValueExpression extends Expression { |
10885 | 10885 | /** |
10886 | 10886 | * @internal |
10887 | 10887 | */ |
10888 | | - _validateUserData(_ignoreUndefinedProperties: boolean): void { |
| 10888 | + _validateUserData(ignoreUndefinedProperties: boolean): void { |
10889 | 10889 | // Casting to bypass type checking becuase _validateUserData does not exist in the public types |
10890 | 10890 | // eslint-disable-next-line @typescript-eslint/no-explicit-any |
10891 | | - (this.pipeline as any)._validateUserData('PipelineValueExpression'); |
| 10891 | + (this.pipeline as any)._validateUserData(ignoreUndefinedProperties); |
10892 | 10892 | } |
10893 | 10893 | } |
10894 | 10894 |
|
|
Collapse file
Copy file name to clipboardExpand all lines: handwritten/firestore/dev/system-test/pipeline.ts +24Lines changed: 24 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -6216,6 +6216,30 @@ describe.skipClassic('Pipeline class', () => { |
6216 | 6216 | }); |
6217 | 6217 | }); |
6218 | 6218 |
|
| 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 | + |
6219 | 6243 | it('multiple array subqueries', async () => { |
6220 | 6244 | const reviewsCollectionName = `reviews_multi_${Date.now()}`; |
6221 | 6245 | const authorsCollectionName = `authors_multi_${Date.now()}`; |
|