googleapis / googleapis/google-cloud-node
Nested object with all `undefined` fields causes entire nested chain to be omitted
- Dominant language
- TypeScript
- Stars
- 3.2k
- Forks
- 712
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 99
Description
Consider an operation like so:
```js
ref.set({
a: {
b: {
c: undefined
}
})
```
With `ignoreUndefinedProperties: true`, I would have expected the result written to Firestore to be
```js
{
a: {
b: {}
}
}
```
However the actual result is that the entire `a`→`b`→`c` nested chain is entirely omitted:
```js
{}
```
Is this the intended behaviour?
I believe it is due to these lines below, which, when there are no other non-`undefined` fields in any of the objects, flows all the way up the chain causing the entire nested chain to be omitted.
https://github.com/googleapis/nodejs-firestore/blob/ac35b372faf32f093d83af18d487f1b3f23ee673/dev/src/serializer.ts#L205-L207
Essentially those lines mean than an object consisting entirely of `undefined` fields should be omitted (the object itself), rather than just serialised as an empty object.
Tested on `@google-cloud/firestore` version: `6.7.0`.
Contributor guide
Assessment
This issue has not been assessed yet.