[PR #7436] fix(drizzle-adapter): support timestamp columns with { mode: "string" } #32912

Open
opened 2026-04-17 23:37:06 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/7436
Author: @ChetanReddyC
Created: 1/17/2026
Status: 🔄 Open

Base: mainHead: fix/drizzle-timestamp-mode-string-7419


📝 Commits (2)

  • 50706fb fix(drizzle-adapter): support timestamp mode string
  • 5c52fe8 Merge branch 'canary' into fix/drizzle-timestamp-mode-string-7419

📊 Changes

1 file changed (+111 additions, -0 deletions)

View changed files

e2e/adapter/test/drizzle-adapter/timestamp-mode-string.test.ts (+111 -0)

📄 Description

Fixes #7419

Description

This PR fixes an issue where the Drizzle adapter causes a crash when using timestamp columns configured with { mode: "string" } in the Drizzle schema.

The adapter was passing Date objects to Drizzle, but columns with mode: "string" strictly expect string values. This fix intercepts Date objects and converts them to ISO strings when the target column is configured with dataType: "string".

Changes

  • Added [customTransformInput] hook to drizzle-adapter to detect { mode: "string" } columns and convert input dates to ISO strings.
  • Added unit tests to verify proper handling of string-mode timestamps vs default date-mode timestamps.

Verification

  • Verified using a new unit test suite [timestamp-mode-string.test.ts]
  • Manually verified using a demo app with Drizzle, confirming successful user creation without errors.

Screenshots

Fix_Screenshot

Verification showing successful signup with { mode: "string" } schema, returning valid ISO string timestamps.

Test Execution Logs

 RUN  v4.0.16 C:/Users/chait/OneDrive/Desktop/opensorce contributions/better-auth/packages/better-auth

 ✓ src/adapters/drizzle-adapter/test/timestamp-mode-string.test.ts (4 tests) 17ms
   ✓ drizzle adapter - timestamp mode string support (unit test) (4)  
     ✓ should convert Date to ISO string when Drizzle column has dataType: 'string' (mode: 'string') 8ms
     ✓ should NOT convert Date when Drizzle column has dataType: 'date' (mode: 'date') 2ms     
     ✓ should NOT convert non-Date values 1ms
     ✓ should handle missing schema gracefully 1ms

 Test Files  1 passed (1)
      Tests  4 passed (4)
   Start at  15:31:06   
   Duration  3.41s 

---

<sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/7436 **Author:** [@ChetanReddyC](https://github.com/ChetanReddyC) **Created:** 1/17/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/drizzle-timestamp-mode-string-7419` --- ### 📝 Commits (2) - [`50706fb`](https://github.com/better-auth/better-auth/commit/50706fbbd3585216ba2a59f8e3f3a57b51e6502c) fix(drizzle-adapter): support timestamp mode string - [`5c52fe8`](https://github.com/better-auth/better-auth/commit/5c52fe85b8432ff1bdcd283d3470c98fbf1f7720) Merge branch 'canary' into fix/drizzle-timestamp-mode-string-7419 ### 📊 Changes **1 file changed** (+111 additions, -0 deletions) <details> <summary>View changed files</summary> ➕ `e2e/adapter/test/drizzle-adapter/timestamp-mode-string.test.ts` (+111 -0) </details> ### 📄 Description Fixes #7419 ## Description This PR fixes an issue where the Drizzle adapter causes a crash when using `timestamp` columns configured with `{ mode: "string" }` in the Drizzle schema. The adapter was passing `Date` objects to Drizzle, but columns with `mode: "string"` strictly expect string values. This fix intercepts `Date` objects and converts them to ISO strings when the target column is configured with `dataType: "string"`. ## Changes - Added [customTransformInput] hook to `drizzle-adapter` to detect `{ mode: "string" }` columns and convert input dates to ISO strings. - Added unit tests to verify proper handling of string-mode timestamps vs default date-mode timestamps. ## Verification - Verified using a new unit test suite [timestamp-mode-string.test.ts] - Manually verified using a demo app with Drizzle, confirming successful user creation without errors. ## Screenshots <img width="1918" height="962" alt="Fix_Screenshot" src="https://github.com/user-attachments/assets/db444ca7-6341-46b8-8c00-854f6af49427" /> *Verification showing successful signup with `{ mode: "string" }` schema, returning valid ISO string timestamps.* ### Test Execution Logs ```text RUN v4.0.16 C:/Users/chait/OneDrive/Desktop/opensorce contributions/better-auth/packages/better-auth ✓ src/adapters/drizzle-adapter/test/timestamp-mode-string.test.ts (4 tests) 17ms ✓ drizzle adapter - timestamp mode string support (unit test) (4) ✓ should convert Date to ISO string when Drizzle column has dataType: 'string' (mode: 'string') 8ms ✓ should NOT convert Date when Drizzle column has dataType: 'date' (mode: 'date') 2ms ✓ should NOT convert non-Date values 1ms ✓ should handle missing schema gracefully 1ms Test Files 1 passed (1) Tests 4 passed (4) Start at 15:31:06 Duration 3.41s --- <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-17 23:37:06 -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#32912