Skip to content

fix: Support boolean column filters in where() and having()#1304

Merged
kevin-dp merged 5 commits intoTanStack:mainfrom
kevin-dp:boolean-cols
Feb 26, 2026
Merged

fix: Support boolean column filters in where() and having()#1304
kevin-dp merged 5 commits intoTanStack:mainfrom
kevin-dp:boolean-cols

Conversation

@kevin-dp
Copy link
Contributor

@kevin-dp kevin-dp commented Feb 26, 2026

Summary

  • Converts ref proxies to PropRef expressions in where() and having() before the isExpressionLike validation, enabling idiomatic boolean filters:
    • .where(({ u }) => u.active) instead of .where(({ u }) => eq(u.active, true))
    • .where(({ u }) => not(u.active)) instead of .where(({ u }) => eq(u.active, false))
    • .having(({ $selected }) => $selected.isHighVolume) for computed boolean fields
  • Adds unit tests for bare and negated boolean column refs in both where and having clauses

Test plan

  • bare boolean column reference as where filter — filters to active employees
  • negated boolean column reference as where filter — filters to inactive employees
  • having with bare boolean selected field — filters grouped results by computed boolean
  • having with negated boolean selected field — filters grouped results by negated boolean
  • All existing tests pass (2006 tests)

Closes #1303

🤖 Generated with Claude Code

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 26, 2026

More templates

@tanstack/angular-db

npm i https://pkg.pr.new/@tanstack/angular-db@1304

@tanstack/db

npm i https://pkg.pr.new/@tanstack/db@1304

@tanstack/db-ivm

npm i https://pkg.pr.new/@tanstack/db-ivm@1304

@tanstack/electric-db-collection

npm i https://pkg.pr.new/@tanstack/electric-db-collection@1304

@tanstack/offline-transactions

npm i https://pkg.pr.new/@tanstack/offline-transactions@1304

@tanstack/powersync-db-collection

npm i https://pkg.pr.new/@tanstack/powersync-db-collection@1304

@tanstack/query-db-collection

npm i https://pkg.pr.new/@tanstack/query-db-collection@1304

@tanstack/react-db

npm i https://pkg.pr.new/@tanstack/react-db@1304

@tanstack/rxdb-db-collection

npm i https://pkg.pr.new/@tanstack/rxdb-db-collection@1304

@tanstack/solid-db

npm i https://pkg.pr.new/@tanstack/solid-db@1304

@tanstack/svelte-db

npm i https://pkg.pr.new/@tanstack/svelte-db@1304

@tanstack/trailbase-db-collection

npm i https://pkg.pr.new/@tanstack/trailbase-db-collection@1304

@tanstack/vue-db

npm i https://pkg.pr.new/@tanstack/vue-db@1304

commit: d8ea072

@changeset-bot
Copy link

changeset-bot bot commented Feb 26, 2026

🦋 Changeset detected

Latest commit: d8ea072

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

This PR includes changesets to release 12 packages
Name Type
@tanstack/db Patch
@tanstack/angular-db Patch
@tanstack/electric-db-collection Patch
@tanstack/offline-transactions Patch
@tanstack/powersync-db-collection Patch
@tanstack/query-db-collection Patch
@tanstack/react-db Patch
@tanstack/rxdb-db-collection Patch
@tanstack/solid-db Patch
@tanstack/svelte-db Patch
@tanstack/trailbase-db-collection Patch
@tanstack/vue-db 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

autofix-ci bot and others added 2 commits February 26, 2026 09:43
Convert ref proxies to PropRef expressions before the isExpressionLike
validation, allowing idiomatic boolean filters like
`.where(({ u }) => u.active)` and `.having(({ s }) => s.isActive)`.

Closes TanStack#1303

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@kevin-dp kevin-dp changed the title test: Add unit tests for boolean column filters fix: Support boolean column filters in where() and having() Feb 26, 2026
kevin-dp and others added 2 commits February 26, 2026 11:00
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Collaborator

@samwillis samwillis left a comment

Choose a reason for hiding this comment

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

:shipit: 🔥

@kevin-dp kevin-dp merged commit e9d0fd8 into TanStack:main Feb 26, 2026
7 checks passed
@github-actions github-actions bot mentioned this pull request Feb 26, 2026
kevin-dp added a commit that referenced this pull request Feb 26, 2026
…risons

Replace eq(x, false) with not(x) and eq(x, true) with bare boolean refs
in query examples, aligning docs with the idiomatic API supported by #1304.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
KyleAMathews pushed a commit that referenced this pull request Feb 26, 2026
docs: Use idiomatic boolean filters instead of eq() for boolean comparisons

Replace eq(x, false) with not(x) and eq(x, true) with bare boolean refs
in query examples, aligning docs with the idiomatic API supported by #1304.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Contributor

🎉 This PR has been released!

Thank you for your contribution!

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.

bug: filtering on boolean columns

2 participants