googleapis / googleapis/google-cloud-node

Nested object with all `undefined` fields causes entire nested chain to be omitted

Offen
#7,465 1 Kommentar 1 Reaktion 1 zugewiesene Person Beansprucht von @dconeybe Auf GitHub ansehen
api: firestore library: nodejs-firestore priority: p2 type: bug
Vorherrschende Sprache
TypeScript
Sterne
3.2k
Forks
712
Ø Merge
2 T. 9 Std.
Gemergte PRs (30 T.)
104

Beschreibung

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`.

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.