fieldName causes blank fields when getting session #905

Closed
opened 2026-03-13 08:09:19 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @ChetdeJong on GitHub (Mar 23, 2025).

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

When having fieldName setup in certain way it messes with drizzle adapter query resulting in field being always undefined.

Setup:

export const auth = betterAuth({
	user: {
		additionalFields: {
			someField: {
				type: 'boolean',
				fieldName: 'some_field',
			}
		}
	},
// rest of config

The issue lies here
https://github.com/better-auth/better-auth/blob/main/packages/better-auth/src/adapters/drizzle-adapter/drizzle-adapter.ts#L193

Workaround is either not setting fieldName at all or making it match the key, which makes it pointless.

Current vs. Expected behavior

Not sure if it's intended behavior, I might be wrong.

What version of Better Auth are you using?

1.2.4

Provide environment information

Postgres, drizzle adapter. Same result with both pg and postgres packages.

Which area(s) are affected? (Select all that apply)

Backend

Originally created by @ChetdeJong on GitHub (Mar 23, 2025). ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce When having `fieldName` setup in certain way it messes with drizzle adapter query resulting in field being always undefined. Setup: ```ts export const auth = betterAuth({ user: { additionalFields: { someField: { type: 'boolean', fieldName: 'some_field', } } }, // rest of config ``` The issue lies here https://github.com/better-auth/better-auth/blob/main/packages/better-auth/src/adapters/drizzle-adapter/drizzle-adapter.ts#L193 Workaround is either not setting `fieldName` at all or making it match the key, which makes it pointless. ### Current vs. Expected behavior Not sure if it's intended behavior, I might be wrong. ### What version of Better Auth are you using? 1.2.4 ### Provide environment information Postgres, drizzle adapter. Same result with both `pg` and `postgres` packages. ### Which area(s) are affected? (Select all that apply) Backend
GiteaMirror added the bug label 2026-03-13 08:09:19 -05:00
Author
Owner

@Bekacru commented on GitHub (Mar 24, 2025):

You shouldn't specify fieldName unless that is the field name in your drizzle schema. Better Auth works at ORM level when you use an adapter.

@Bekacru commented on GitHub (Mar 24, 2025): You shouldn't specify fieldName unless that is the field name in your drizzle schema. Better Auth works at ORM level when you use an adapter.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#905