[PR #5795] [CLOSED] Fix: string[] additionalFields inferred as number[] #23130

Closed
opened 2026-04-15 21:30:25 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/5795
Author: @VishalDevx
Created: 11/6/2025
Status: Closed

Base: canaryHead: fix/additional-fiels-string-array


📝 Commits (1)

  • 30c1149 Fix: string[] additionalFields inferred as number[]

📊 Changes

1 file changed (+20 additions, -17 deletions)

View changed files

📝 packages/better-auth/src/db/field.ts (+20 -17)

📄 Description

Summary

This PR fixes an issue where additional fields defined with the type string[]
were being incorrectly inferred as number[] during schema inference.

Root Cause

The type inference logic in InferValueType did not properly handle
string[] cases due to incorrect conditional type resolution.

Changes

  • Updated InferValueType in packages/better-auth/src/db/field.ts to correctly infer string[] fields.
  • Added support for distinguishing array types of string, number, boolean, and date.
  • Ensured type inference returns the correct array element type for all supported DB field types.

Impact

This resolves incorrect type mapping for array fields and prevents runtime type mismatches when dealing with additional schema fields.

Testing

  • Verified type inference manually for:
    • string[]
    • number[]
    • boolean[]
    • date[]
  • All types are now correctly resolved by TypeScript.

Summary by cubic

Fixes incorrect schema inference that mapped additionalFields typed as string[] to number[]. Updates InferValueType to correctly handle array and scalar DB field types (string, number, boolean, date), preventing type mismatches.

Written for commit 30c1149490. Summary will update automatically 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/5795 **Author:** [@VishalDevx](https://github.com/VishalDevx) **Created:** 11/6/2025 **Status:** ❌ Closed **Base:** `canary` ← **Head:** `fix/additional-fiels-string-array` --- ### 📝 Commits (1) - [`30c1149`](https://github.com/better-auth/better-auth/commit/30c1149490ebe3d7b48b0f44a1366a7c7acf926d) Fix: string[] additionalFields inferred as number[] ### 📊 Changes **1 file changed** (+20 additions, -17 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/db/field.ts` (+20 -17) </details> ### 📄 Description ### Summary This PR fixes an issue where additional fields defined with the type `string[]` were being incorrectly inferred as `number[]` during schema inference. ### Root Cause The type inference logic in `InferValueType` did not properly handle `string[]` cases due to incorrect conditional type resolution. ### Changes - Updated `InferValueType` in `packages/better-auth/src/db/field.ts` to correctly infer `string[]` fields. - Added support for distinguishing array types of `string`, `number`, `boolean`, and `date`. - Ensured type inference returns the correct array element type for all supported DB field types. ### Impact This resolves incorrect type mapping for array fields and prevents runtime type mismatches when dealing with additional schema fields. ### Testing - Verified type inference manually for: - `string[]` - `number[]` - `boolean[]` - `date[]` - All types are now correctly resolved by TypeScript. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Fixes incorrect schema inference that mapped additionalFields typed as string[] to number[]. Updates InferValueType to correctly handle array and scalar DB field types (string, number, boolean, date), preventing type mismatches. <sup>Written for commit 30c1149490ebe3d7b48b0f44a1366a7c7acf926d. Summary will update automatically 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-04-15 21:30:25 -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#23130