You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
db-postgres: OR filters on two text fields in the same block throw a duplicate JOIN alias error #19459
With PostgreSQL and the default relational Blocks storage, two valid text paths under the same Block type work independently but throw when combined with or in one Local API find. This also affects Admin List Search if both paths are in admin.listSearchableFields, since it combines the fields with or.
Point DATABASE_URL at a new disposable PostgreSQL database (the script uses schema push). Run NODE_ENV=development DATABASE_URL='<disposable-postgres-url>' node repro.mjs.
The script creates one article with a card block and runs three queries: layout.heading, layout.caption, and { or: [headingCondition, captionCondition] }.
Expected: all three queries return totalDocs: 1.
Actual:
{"layout.heading":{"like":"needle"}} 1
{"layout.caption":{"like":"needle"}} 1
Error: Alias "articles_blocks_card" is already used in this query
The same script reproduces on 4.0.0-beta.7 with both dependencies set to that version and a fresh database. No Next.js or Admin setup is needed.
The Blocks path resolver appends the parent block join for each matched path. Both paths resolve to the same table, so Drizzle throws when building the second join. This is distinct from #8517 / #8823, which addressed normal Array fields.
Which area(s) are affected?
db: postgres
Environment Info
Payload and @payloadcms/db-postgres: 3.93.0 and 4.0.0-beta.7, tested separately
PostgreSQL: 17.11
Node.js: 24.21.0
Next.js: not used (standalone Local API reproduction)
Activity
fix(drizzle): dedupe block joins for multi-field OR/AND queries
muhammad-wasif-code commentedon Nov 10, 2026
Opened a PR that dedupes relational Blocks joins when the same block table is referenced by multiple fields in one
or/andquery: #19477It includes a regression test covering single-field,
or, andandqueries.fix: address 24 Payload read, schema, version and tooling reports (#9)