Skip to content

fix(drizzle): handle empty in queries on polymorphic relationships#17372

Open
rasitakyol wants to merge 1 commit into
payloadcms:mainfrom
rasitakyol:codex/fix-empty-polymorphic-in
Open

fix(drizzle): handle empty in queries on polymorphic relationships#17372
rasitakyol wants to merge 1 commit into
payloadcms:mainfrom
rasitakyol:codex/fix-empty-polymorphic-in

Conversation

@rasitakyol

Copy link
Copy Markdown
Contributor

What?

Keep polymorphic relationship columns when a Drizzle in query receives an empty array.

Why?

The type-pruning guards treated an empty array as matching every value-type check. For UUID-backed polymorphic relationships, this removed every query column, dropped the filter entirely, and returned all documents instead of none.

How?

Apply the existing numeric and UUID type-pruning rules only to non-empty arrays. A focused integration test creates a polymorphic relationship, queries it with in: [], verifies that no documents are returned, and cleans up its records.

Validation:

  • PAYLOAD_DATABASE=sqlite-uuid pnpm test:int relationships (58 passed, 4 skipped)
  • PAYLOAD_DATABASE=postgres-uuid pnpm test:int relationships (58 passed, 4 skipped)
  • pnpm build:drizzle
  • Prettier, ESLint, and git diff --check on the changed files

Fixes #16195

@rasitakyol
rasitakyol marked this pull request as ready for review July 16, 2026 21:01
@rasitakyol
rasitakyol force-pushed the codex/fix-empty-polymorphic-in branch from ff44b33 to 5792bd7 Compare July 19, 2026 07:58
@rasitakyol

rasitakyol commented Jul 19, 2026

Copy link
Copy Markdown
Contributor Author

CI note after rebasing onto current main to trigger the previously approval-blocked full workflow: build, lint, and 164 checks are passing.

LexicalAutosaveBlock, LexicalJSXConverter, and LexicalLinkFeature all failed during Payload initialization with the same transient MongoDB catalog-change error (payload._array-fields_versions, payloadInitError: true). The editor was then absent on every retry, before the suite logic could exercise this Drizzle query patch. The same initialization signature occurred concurrently across #17354, #17355, #17371, and #17372, whose diffs are unrelated. All Green is only the aggregate failure; the cancelled notify-next-canary jobs are ancillary concurrency cancellations.

No patch change is indicated by these logs. A maintainer rerun of the failed E2E jobs would be appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

in doesn't filter polymorphic relationship when using uuid and empty array

1 participant