lucia-auth / lucia

Authentication, simple and clean
https://lucia-auth.com
MIT License
9.25k stars 471 forks source link

Fix DrizzleSQLiteAdapter constructor signature #1426

Closed yu7400ki closed 7 months ago

yu7400ki commented 7 months ago

In the signature of the DrizzleSQLiteAdapter constructor, the generic type TFullSchema of BaseSQLiteDatabase was not set. Consequently, an instance with a schema couldn't be passed.

example ```ts import { DrizzleSQLiteAdapter } from "@lucia-auth/adapter-drizzle"; import { Database } from "bun:sqlite"; import { sqliteTable, text, integer } from "drizzle-orm/sqlite-core"; import { drizzle } from "drizzle-orm/bun-sqlite"; const sqliteDB = new Database(":memory:"); const userTable = sqliteTable("user", { id: text("id").notNull().primaryKey(), }); const sessionTable = sqliteTable("user_session", { id: text("id").notNull().primaryKey(), userId: text("user_id") .notNull() .references(() => userTable.id), expiresAt: integer("expires_at").notNull(), }); const db = drizzle(sqliteDB); new DrizzleSQLiteAdapter(db, sessionTable, userTable); // <- OK const dbWithSchema = drizzle(sqliteDB, { schema: { userTable, sessionTable } }); new DrizzleSQLiteAdapter(dbWithSchema, sessionTable, userTable); // <- Error ```
pilcrowOnPaper commented 7 months ago

Do you know if this is just an issue with SQLite? I know someone had issues with MySQL as well

yu7400ki commented 7 months ago

Do you know if this is just an issue with SQLite? I know someone had issues with MySQL as well

In MySQL, the initial value of TFullSchema is set to {}, so I don't think this problem would occur. If you're interested, could you please share more details about that particular issue?

As for Postgres, since any is already set, I don't anticipate encountering a similar problem there.

yu7400ki commented 7 months ago

Having said that, setting any for all generics of SQLiteDatabase and other Databases might not be a bad idea.

pilcrowOnPaper commented 7 months ago

Thanks!