Skip to content

[wip] fix undefined filters in Drizzle connections - #1647

Closed
williamrobertson13 wants to merge 2 commits into
hayes:mainfrom
williamrobertson13:agent/omit-undefined-drizzle-connection-filter
Closed

[wip] fix undefined filters in Drizzle connections#1647
williamrobertson13 wants to merge 2 commits into
hayes:mainfrom
williamrobertson13:agent/omit-undefined-drizzle-connection-filter

Conversation

@williamrobertson13

Copy link
Copy Markdown
Contributor

Summary

  • omit where from generated Drizzle connection queries when there is no filter
  • cover both root drizzleConnection and nested relatedConnection query shapes
  • add a patch changeset for @pothos/plugin-drizzle

Why

Drizzle 1.0.0-rc.5-169397b rejects an explicitly undefined relational filter with:

Unexpected 'undefined' in filter value. Use 'EmptyFilter' if you want the filter field to be skipped.

Connection queries without a user filter or cursor currently include where: undefined. Omitting the optional property preserves existing behavior on earlier Drizzle versions and satisfies the stricter rc.5 contract.

Validation

  • regression assertions fail on both affected query paths before the fix
  • drizzle-orm@1.0.0-rc.2: 90/90 plugin tests pass
  • drizzle-orm@1.0.0-rc.4: 90/90 plugin tests pass
  • drizzle-orm@1.0.0-rc.5-169397b: 90/90 plugin tests pass
  • pnpm --filter @pothos/plugin-drizzle type
  • pnpm --filter @pothos/plugin-drizzle build

@vercel

vercel Bot commented Aug 18, 2026

Copy link
Copy Markdown

@williamrobertson13 is attempting to deploy a commit to the Michael Hayes' projects Team on Vercel.

A member of the Team first needs to authorize it.

@changeset-bot

changeset-bot Bot commented Aug 18, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 2f801f3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@pothos/plugin-drizzle Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@williamrobertson13 williamrobertson13 changed the title Fix undefined filters in Drizzle connections [wip] fix undefined filters in Drizzle connections Aug 18, 2026
@pkg-pr-new

pkg-pr-new Bot commented Aug 18, 2026

Copy link
Copy Markdown

Open in StackBlitz

@pothos/core

npm i https://pkg.pr.new/@pothos/core@1647

@pothos/plugin-add-graphql

npm i https://pkg.pr.new/@pothos/plugin-add-graphql@1647

@pothos/plugin-complexity

npm i https://pkg.pr.new/@pothos/plugin-complexity@1647

@pothos/plugin-dataloader

npm i https://pkg.pr.new/@pothos/plugin-dataloader@1647

@pothos/plugin-directives

npm i https://pkg.pr.new/@pothos/plugin-directives@1647

@pothos/plugin-drizzle

npm i https://pkg.pr.new/@pothos/plugin-drizzle@1647

@pothos/plugin-errors

npm i https://pkg.pr.new/@pothos/plugin-errors@1647

@pothos/plugin-example

npm i https://pkg.pr.new/@pothos/plugin-example@1647

@pothos/plugin-federation

npm i https://pkg.pr.new/@pothos/plugin-federation@1647

@pothos/plugin-grafast

npm i https://pkg.pr.new/@pothos/plugin-grafast@1647

@pothos/plugin-mocks

npm i https://pkg.pr.new/@pothos/plugin-mocks@1647

@pothos/plugin-prisma

npm i https://pkg.pr.new/@pothos/plugin-prisma@1647

@pothos/plugin-prisma-utils

npm i https://pkg.pr.new/@pothos/plugin-prisma-utils@1647

@pothos/plugin-relay

npm i https://pkg.pr.new/@pothos/plugin-relay@1647

@pothos/plugin-scope-auth

npm i https://pkg.pr.new/@pothos/plugin-scope-auth@1647

@pothos/plugin-simple-objects

npm i https://pkg.pr.new/@pothos/plugin-simple-objects@1647

@pothos/plugin-smart-subscriptions

npm i https://pkg.pr.new/@pothos/plugin-smart-subscriptions@1647

@pothos/plugin-sub-graph

npm i https://pkg.pr.new/@pothos/plugin-sub-graph@1647

@pothos/plugin-tracing

npm i https://pkg.pr.new/@pothos/plugin-tracing@1647

@pothos/plugin-validation

npm i https://pkg.pr.new/@pothos/plugin-validation@1647

@pothos/plugin-with-input

npm i https://pkg.pr.new/@pothos/plugin-with-input@1647

@pothos/plugin-zod

npm i https://pkg.pr.new/@pothos/plugin-zod@1647

@pothos/tracing-newrelic

npm i https://pkg.pr.new/@pothos/tracing-newrelic@1647

@pothos/tracing-opentelemetry

npm i https://pkg.pr.new/@pothos/tracing-opentelemetry@1647

@pothos/tracing-sentry

npm i https://pkg.pr.new/@pothos/tracing-sentry@1647

@pothos/tracing-xray

npm i https://pkg.pr.new/@pothos/tracing-xray@1647

commit: 2f801f3

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates @pothos/plugin-drizzle connection query generation to avoid emitting where: undefined in Drizzle relational queries, improving compatibility with stricter Drizzle 1.0.0-rc.5 filtering behavior. It also adds regression tests for both root and nested connection shapes and includes a patch changeset for release.

Changes:

  • Omit where from generated connection query objects when no filter clauses exist.
  • Ensure combined where logic for connection + user-provided query is only included when defined.
  • Add regression tests (root drizzleConnection and nested relatedConnection) plus a patch changeset.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
packages/plugin-drizzle/src/utils/cursors.ts Avoids generating where: undefined by conditionally adding where only when a filter exists.
packages/plugin-drizzle/tests/drizzle-connections.test.ts Adds a regression assertion (via spy) that root connection queries omit where when undefined.
packages/plugin-drizzle/tests/related-connection.test.ts Adds a regression assertion (via spy) that nested related connection queries omit where when undefined.
.changeset/quiet-ravens-filter.md Adds a patch changeset describing the compatibility fix for strict Drizzle relational filters.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines 896 to +898
});

expect(findMany.mock.calls[0][0]).not.toHaveProperty('where');
Comment thread packages/plugin-drizzle/tests/related-connection.test.ts
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@williamrobertson13

Copy link
Copy Markdown
Contributor Author

closing this until RC 5 gets released for real

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.

2 participants