googleapis / googleapis/google-cloud-node

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

Aperta
#7,465 1 commento 1 reazione 1 assegnatario Vedi su GitHub

@dconeybe ci sta già lavorando.

Dal 9/8/2023.

api: firestore library: nodejs-firestore priority: p2 type: bug
Lingua principale
TypeScript
Stelle
3.2k
Fork
713
Merge medio
2g 9h
PR unite (30g)
104

Descrizione

Consider an operation like so:

ref.set({
  a: {
    b: {
      c: undefined
    }
})

With ignoreUndefinedProperties: true, I would have expected the result written to Firestore to be

{
  a: {
    b: {}
  }
}

However the actual result is that the entire abc nested chain is entirely omitted:

{}

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.

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.