You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SlavenIvanov opened this issue
May 9, 2024
· 0 comments
Labels
adaptersChanges related to the core code concerning database adaptersbugSomething isn't workingtriageUnseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.
System:
OS: macOS 14.3.1
CPU: (10) arm64 Apple M1 Max
Memory: 3.57 GB / 32.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.11.0 - ~/.nvm/versions/node/v20.11.0/bin/node
Yarn: 1.22.22 - /opt/homebrew/bin/yarn
npm: 10.2.4 - ~/.nvm/versions/node/v20.11.0/bin/npm
bun: 1.1.4 - /opt/homebrew/bin/bun
Browsers:
Brave Browser: 124.1.65.130
Chrome: 124.0.6367.119
Safari: 17.3.1
npmPackages:
@auth/drizzle-adapter: ^1.0.1 => 1.0.1
@auth/sveltekit: ^1.0.1 => 1.0.1 ```
### Reproduction URL
https://github.com/SlavenIvanov/authjs-drizzle-issue
### Describe the issue
The DrizzleKit adapter doesn't respect the `$defaultFn()`/`$default()` set to the `user.id` specified in the schema, during user creation.
```ts
import { nanoid } from 'nanoid'
export const users = pgTable('user', {
id: text('id')
.primaryKey()
.$defaultFn(() => nanoid()), // 👈 this here
name: text('name'),
email: text('email').notNull(),
emailVerified: timestamp('emailVerified', { mode: 'date' }),
image: text('image'),
})
How to reproduce
Clone repo
CD into repo
npm i
docker-compose up -d
Add your OAuth GH credentails in .env
npm run drizzle:push
npm run dev 👉 pageApp
npm run drizzle:studio and open drizzle studio 👉 pageDrizzle
now in pageApp click on Sign In
Open pageDrizzle and navigate to the user table
The Id should be a nanoid() but is a uuid
And we know that the drizzle schema is correct because if you create a new user manually:
The id is correctly picking up the nanoid()
Expected behavior
DrizzleKit Adapter should call the $default()/$defaultFn() instead of generating a uuid for the user.id
The text was updated successfully, but these errors were encountered:
SlavenIvanov
added
adapters
Changes related to the core code concerning database adapters
bug
Something isn't working
triage
Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.
labels
May 9, 2024
adaptersChanges related to the core code concerning database adaptersbugSomething isn't workingtriageUnseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.
Adapter type
@auth/drizzle-adapter
Environment
How to reproduce
npm i
docker-compose up -d
npm run drizzle:push
npm run dev
👉 pageAppnpm run drizzle:studio
and open drizzle studio 👉 pageDrizzleuser
tableThe Id should be a
nanoid()
but is auuid
And we know that the drizzle schema is correct because if you create a new user manually:
The id is correctly picking up the
nanoid()
Expected behavior
DrizzleKit Adapter should call the
$default()
/$defaultFn()
instead of generating a uuid for theuser.id
The text was updated successfully, but these errors were encountered: