[PR #8176] [MERGED] fix(adapter): map camelCase keys during checkMissingFields in Drizzle adapter #7796

Closed
opened 2026-03-13 13:49:27 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/8176
Author: @jonathan-teamstatus
Created: 2/26/2026
Status: Merged
Merged: 2/27/2026
Merged by: @himself65

Base: canaryHead: fix/drizzle-adapter-check-missing-fields


📝 Commits (5)

  • b1f5c8f fix(adapter): use getFieldName in checkMissingFields to map camelCase
  • e1a64b0 fix(adapter): handle getFieldName throw in checkMissingFields and add tests
  • 1119fef fix: format drizzle-adapter test to pass biome check
  • e6dbcc0 Merge branch 'canary' into fix/drizzle-adapter-check-missing-fields
  • 90ab916 Merge branch 'canary' into fix/drizzle-adapter-check-missing-fields

📊 Changes

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

View changed files

📝 packages/drizzle-adapter/src/drizzle-adapter.test.ts (+118 -1)
📝 packages/drizzle-adapter/src/drizzle-adapter.ts (+7 -1)

📄 Description

Description

Fixes a bug where auth.api.signUpEmail() fails with FAILED_TO_CREATE_USER (422) when using the Drizzle adapter with camelCase field names.

The checkMissingFields function previously iterated over camelCase keys in values (e.g., emailVerified) and checked if they existed directly on the schema object, which contains snake_case property names (e.g., email_verified).

This PR updates checkMissingFields to use getFieldName({ model, field: key }) to resolve the correct Drizzle schema property name before checking for its existence, making it consistent with how every other function in the adapter currently works.

Testing

  • Verified that getFieldName correctly maps the incoming camelCase keys to their respective schema representations before validation.

🔄 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/8176 **Author:** [@jonathan-teamstatus](https://github.com/jonathan-teamstatus) **Created:** 2/26/2026 **Status:** ✅ Merged **Merged:** 2/27/2026 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `fix/drizzle-adapter-check-missing-fields` --- ### 📝 Commits (5) - [`b1f5c8f`](https://github.com/better-auth/better-auth/commit/b1f5c8f3e8eef18123472147dc108c87dddf0f60) fix(adapter): use getFieldName in checkMissingFields to map camelCase - [`e1a64b0`](https://github.com/better-auth/better-auth/commit/e1a64b02ea55646dc585bc0514746acdd68a61cb) fix(adapter): handle getFieldName throw in checkMissingFields and add tests - [`1119fef`](https://github.com/better-auth/better-auth/commit/1119fef2afa57f2e7250ff9c3c9db894016922b2) fix: format drizzle-adapter test to pass biome check - [`e6dbcc0`](https://github.com/better-auth/better-auth/commit/e6dbcc042346f47e170b9232c40798bab21cba11) Merge branch 'canary' into fix/drizzle-adapter-check-missing-fields - [`90ab916`](https://github.com/better-auth/better-auth/commit/90ab916187527cb6e856356c187da13d8e7b3bff) Merge branch 'canary' into fix/drizzle-adapter-check-missing-fields ### 📊 Changes **2 files changed** (+125 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `packages/drizzle-adapter/src/drizzle-adapter.test.ts` (+118 -1) 📝 `packages/drizzle-adapter/src/drizzle-adapter.ts` (+7 -1) </details> ### 📄 Description ## Description Fixes a bug where `auth.api.signUpEmail()` fails with `FAILED_TO_CREATE_USER` (422) when using the Drizzle adapter with camelCase field names. The [checkMissingFields](cci:1://file:///home/jonathan/Documents/projects/better-auth/packages/drizzle-adapter/src/drizzle-adapter.ts:334:3-352:4) function previously iterated over camelCase keys in `values` (e.g., `emailVerified`) and checked if they existed directly on the `schema` object, which contains snake_case property names (e.g., `email_verified`). This PR updates [checkMissingFields](cci:1://file:///home/jonathan/Documents/projects/better-auth/packages/drizzle-adapter/src/drizzle-adapter.ts:334:3-352:4) to use `getFieldName({ model, field: key })` to resolve the correct Drizzle schema property name before checking for its existence, making it consistent with how every other function in the adapter currently works. ## Testing - Verified that `getFieldName` correctly maps the incoming camelCase keys to their respective schema representations before validation. --- <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:49:27 -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#7796