Comments (4)
This should probably be a bug report?
from lucia.
Have you tried using the SQLite Drizzle adapter provided by @lucia-auth/adapter-drizzle
?
from lucia.
Only rudimentary, I just now gave it a more thorough go. When making the switch I'm importing the DrizzleSQLiteAdapter from it, and I'm changing the old LibSQL setup (https://lucia-auth.com/database/sqlite):
const adapter = new LibSQLAdapter(db, { user: "user", session: "session"});
Into the DrizzleSQLite setup (https://lucia-auth.com/database/drizzle):
const adapter = new DrizzleSQLiteAdapter(db, sessionTable, userTable);
Something to be noted is that in this code I actually need to pass the libSQLClient to the adapter in the LibSQL setup instead of the db. For the DrizzleSQLite setup I'm switching to the actual db to make it work. For reference this is how both are configured:
export const libSQLClient = createClient({
url: env.DATABASE_URL,
authToken: env.DATABASE_AUTH_TOKEN
});
export const db = drizzle(libSQLClient, { schema });
After doing so I'm encountering a sessionTable type mismatch for the expiresAt column. The dataType is expected to be "number" but is interpreted as "date". I'm able to resolve this for now by removing the { mode: 'timestamp' } configuration from my Drizzle sessions table:
export const sessions = sqliteTable('sessions', {
id: text('id').primaryKey(),
userId: text('user_id')
.references(() => users.id, { onDelete: 'cascade' })
.notNull(),
expiresAt: integer('expires_at', {
mode: 'timestamp'
}).notNull()
});
After doing so the DrizzleSQLiteAdapter does seem to work with Turso and I'm able to deploy the app with the latest @libsql/client version. As of yet I haven't encountered an error as I did earlier, but I'll need to do more testing to be sure as they didn't always pop-up earlier either.
Judging by this quick implementation the sessionTable dataType mismatch might be a bug in the DrizzleSQLiteAdapter, though I think this might be an issue regardless of whether LibSQL or SQLite is used. I'm guessing the adapter assumes regular SQLite functionality, whereas Drizzle offers a "date" type layered on top of it. We can work around this, but it could be confusing for people who aren't aware of it.
I'll report back when I know more. Thanks for looking into this and also in general for your open source contributions. I'm definitely looking forward for some Copenhagen reading.
from lucia.
Gonna close this for now, but feel free to open another issue if you find any 👍
from lucia.
Related Issues (20)
- Prisma Adapter does not accept Session and User models HOT 3
- RFC: Remove adapter packages HOT 36
- [Bug]: None of the Argon package works for Next.js app HOT 2
- [Bug]: getUserAttributes doesn't include relations field of the user HOT 1
- Global Register types conflicting with each other HOT 1
- [Bug]: Adapter querying all columns, not respecting DatabaseUserAttributes HOT 2
- [Bug]: validateSession returns null. Sveltekit + MongoDB + Lucia HOT 8
- [Docs]: clarify `getUserAttributes()` should mention how it handles the user `id` column HOT 1
- [Feature Request]: Add sequelize ORM support
- lucia auth get data from from different table
- [Bug]: custom sessionId does not work with Drizzle adapter HOT 5
- [Feature Request]: Drizzle pg UUID support on types
- [Bug]: incompatible types with generatedAlwaysAsIdentity
- [Bug]: DrizzleSQLiteAdapter type error breaks build HOT 6
- [Bug]: Lucia using Postgres via Drizzle - Date issue
- [Bug]: validateSession return null in Express Mongoose HOT 7
- [Bug]: Drizzle Adapter not accepting Sessions nor User tables HOT 4
- [Bug]: session table @@map in prisma adapter not working in production (Vercel)
- [Docs]: NextJs validation request problem HOT 2
- [Bug]: Official Website StackBlitz demo is not working
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lucia.