db-postgres: after reordering array rows, a row without a polymorphic relationship inherits the one stored in _rels at its new index
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 55/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- postgresql, typescript
- Ambito
- database
Direzione di ricerca
The issue identifies @payloadcms/drizzle's upsertRow as the affected entry point. Read how it updates positional paths in the Postgres _rels table, then reproduce the reorder with repro-5.ts against an empty PostgreSQL database. It is done when the saved _rels rows contain only relationships present in the data and Login has no inherited reference.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the Bug
In the Postgres adapter, relationships inside arrays are stored in <table>_rels under positional paths (links.0.reference, links.1.reference). On update, upsertRow deletes the existing rels only for the paths it re-inserts. A row whose relationship is absent from the data never clears the rel at its index. In the reproduction, that is a polymorphic relationTo: ['notes'] field shown only for type: 'internal'. After a reorder, such a row inherits the relationship of the row that used to be at its position.
A single-collection relationTo: 'notes' is stored as a column on the array table, so it is not affected. Only relationships that go through _rels are affected: polymorphic ones, and presumably hasMany ones.
Expected: after the update, _rels holds only the relationships present in the saved data, and the moved row's reference is empty.
Link to the code that reproduces this issue
https://github.com/elghaied/payload-v4-reproductions (repro-5.ts)
Reproduction Steps
pnpm install, thencp .env.example .envand pointDATABASE_URLat an empty PostgreSQL databasepnpm repro repro-5.ts
The script creates a menu with [First (internal, reference → a note), Login (external, no reference)], then saves [Login, First] with the same ids, First keeping its reference. Output:
menus_rels rows: [{"path":"links.0.reference","notes_id":3},{"path":"links.1.reference","notes_id":3}]
observed Login.reference: { relationTo: 'notes', value: 3 } expected: null/undefined
Which area(s) are affected?
db-postgres (@payloadcms/drizzle upsertRow)
Environment Info
payload: 4.0.0-beta.9
@payloadcms/db-postgres: 4.0.0-beta.9
Node.js: 24.22.1
PostgreSQL: 17.10
(local API only, no Next.js app)
- Lingua principale
- TypeScript
- Stelle
- 45.8k
- Fork
- 4.4k
- Merge medio
- 2g 16h
- PR unite (30g)
- 251
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di payloadcms/payload
-
db-d1-sqlite: upsert is aliased to updateOne, so payload.kv.set never inserts new keysForse già presa @pcbeingused333 l’ha presa 1 giorno fa. ApertaBug db: d1-sqlite Payload OSS
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
payloadcms/payload#19766 ·
I maintainer di solito rispondono entro 1 giorno
-
Document bar (.doc-controls__content) overflows a 375 px viewport, clips "Created" and fails axe scrollable-region-focusableForse già presa Una pull request collegata a questa issue è aperta o già unita. Apertaarea: ui Bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
payloadcms/payload#19690 ·
I maintainer di solito rispondono entro 1 giorno
-
[v4] Blocks thumbnails croped 3:2Forse già presa @samiarif02 l’ha presa 2 giorni fa. Apertaarea: ui Bug Payload OSS status: needs-triage v3
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
payloadcms/payload#19609 ·
I maintainer di solito rispondono entro 1 giorno
-
Scheduled publish jobs are not deleted when their document is deleted (string id in the job, raw id in the cleanup)Forse già presa @volodymyrshk l’ha presa 10 giorni fa. Apertaarea: core Bug db: sqlite
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
payloadcms/payload#19448 ·
I maintainer di solito rispondono entro 1 giorno
-
plugin-multi-tenant: `isGlobal` collections redirect tenant-scoped users to `/admin` since 3.93.0 (GlobalViewRedirect prop-name mismatch)Forse già presa @JarrodMFlesch l’ha presa 11 giorni fa. ApertaBug plugin: multi-tenant
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
payloadcms/payload#19420 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di payloadcms/payload
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
milind-soni/OpenMausBot#6730 ·
I maintainer di solito rispondono entro 1 giorno
-
`@angular/[email protected]` depends on vulnerable Vite 7.3.7 - GHSA-p4f5-76q4-ffq7 (Critical RCE)Apertaarea: @angular/build
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
angular/angular-cli#34764 ·
I maintainer di solito rispondono entro 1 giorno
-
status/need-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
google-gemini/gemini-cli#30384 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
P2
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 84/100
I maintainer di solito rispondono entro 1 giorno
-
area:image documentation good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno