[PR #7860] [MERGED] fix(core): coerce string where values to match field types in adapter #7596

Closed
opened 2026-03-13 13:42:37 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/7860
Author: @bytaesu
Created: 2/8/2026
Status: Merged
Merged: 2/12/2026
Merged by: @himself65

Base: canaryHead: 2026-02-09/fix/adapter-coerce-string-where-values


📝 Commits (2)

  • bcbf79b fix(core): coerce string where values to match field types in adapter
  • a62f5a2 fix: guard empty string coercion and support number array in where clause

📊 Changes

2 files changed (+86 additions, -2 deletions)

View changed files

📝 packages/better-auth/src/db/db.test.ts (+64 -0)
📝 packages/core/src/db/adapter/factory.ts (+22 -2)

📄 Description

Note

You can see this issue by using filterValue in authClient.admin.listUsers
https://www.better-auth.com/docs/plugins/admin#list-users


Summary by cubic

Coerces string where values in the DB adapter to match schema types (boolean/number), including arrays, and ignores empty strings. This makes filters from HTTP query params work consistently across adapters.

  • Bug Fixes
    • Convert "true"/"false" and numeric strings (and arrays) to typed values based on schema before queries.
    • Guard against empty strings when coercing numbers.
    • Preserve boolean-to-1/0 mapping when the adapter doesn’t support booleans; added tests for boolean, number, and number array "in" coercion in findMany.

Written for commit a62f5a289e. Summary will update on new commits.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/7860 **Author:** [@bytaesu](https://github.com/bytaesu) **Created:** 2/8/2026 **Status:** ✅ Merged **Merged:** 2/12/2026 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `2026-02-09/fix/adapter-coerce-string-where-values` --- ### 📝 Commits (2) - [`bcbf79b`](https://github.com/better-auth/better-auth/commit/bcbf79b363a7346d883bf7b0bcf96598046a39c9) fix(core): coerce string where values to match field types in adapter - [`a62f5a2`](https://github.com/better-auth/better-auth/commit/a62f5a289eeb17a813e09a23b141dd8425e33e87) fix: guard empty string coercion and support number array in where clause ### 📊 Changes **2 files changed** (+86 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/db/db.test.ts` (+64 -0) 📝 `packages/core/src/db/adapter/factory.ts` (+22 -2) </details> ### 📄 Description > [!NOTE] > You can see this issue by using `filterValue` in `authClient.admin.listUsers` > https://www.better-auth.com/docs/plugins/admin#list-users <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Coerces string where values in the DB adapter to match schema types (boolean/number), including arrays, and ignores empty strings. This makes filters from HTTP query params work consistently across adapters. - **Bug Fixes** - Convert "true"/"false" and numeric strings (and arrays) to typed values based on schema before queries. - Guard against empty strings when coercing numbers. - Preserve boolean-to-1/0 mapping when the adapter doesn’t support booleans; added tests for boolean, number, and number array "in" coercion in findMany. <sup>Written for commit a62f5a289eeb17a813e09a23b141dd8425e33e87. Summary will update on new commits.</sup> <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-03-13 13:42:37 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#7596