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
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