[v4] db-postgres: beta.11 saves nested array rows under the wrong parent row

Aperta
#19,798 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@Shehzer-Aurangzeb ci sta già lavorando.

Dal 21/11/2026.

  • #19821 di @Shehzer-Aurangzeb — aperta

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
20/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
nodejs, postgresql, typescript
Ambito
databases

Direzione di ricerca

A fix is already proposed in the linked open PR #19821, so check it before starting. Reproduce first with the gist script (npm run repro) against a local Postgres on 4.0.0-beta.11, then diff the beta.10 and beta.11 changes from #19691 and #18193 in the Postgres adapter's array write path under packages/db-postgres. Done looks like all 12 checks printing OK on beta.11 while the adapter's existing tests still pass.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Bug db: postgres Payload OSS
Describe the Bug

On Postgres, 4.0.0-beta.11 saves nested array rows under the wrong parent row. In a collection with an array field that has its own array field, saving

[{ "label": "A" }, { "label": "Company", "children": [{ "label": "P" }, { "label": "U" }] }]

returns and stores

[{ "label": "A", "children": [{ "label": "P" }, { "label": "U" }] }, { "label": "Company", "children": [] }]

The children of the second row are attached to the first row. It happens on create and update, with and without versions.drafts, and when the document is read back.

4.0.0-beta.10 stores it correctly with the same code. Build 4.0.0-internal.ff27d6e also fails. Beta.11 includes two Postgres changes to array writes (#19691, #18193), which may be related.

Real-world impact: a site menu with dropdown items moves every dropdown's links to the wrong menu item on the next save.

Link to the code that reproduces this issue

https://gist.github.com/Lukio9113/cffebe7565f30cbb91aaf05dff4dc008

Reproduction Steps
  1. Download the gist, npm install.
  2. Create .env with DATABASE_URL= pointing at any Postgres database. The script creates its own schema with push: true and drops it at the end.
  3. npm run repro.
  4. On 4.0.0-beta.11 all 12 checks print WRONG. Change both versions in package.json to 4.0.0-beta.10, reinstall and rerun: all 12 print OK.

Config used:

fields: [{ name: 'navigation', type: 'array', fields: [
  { name: 'label', type: 'text' },
  { name: 'children', type: 'array', fields: [{ name: 'label', type: 'text' }] },
] }]
Which area(s) are affected?

db: postgres

Environment Info
payload: 4.0.0-beta.11
@payloadcms/db-postgres: 4.0.0-beta.11
@payloadcms/drizzle: 4.0.0-beta.11
Node.js: 26.13.1
PostgreSQL: local server
OS: Windows 11
Works on: 4.0.0-beta.10
Lingua principale
TypeScript
Stelle
45.8k
Fork
4.4k
Merge medio
3g 4h
PR unite (30g)
210

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

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.

Altre issue di payloadcms/payload

Tutte le issue di payloadcms/payload

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.