Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix DrizzleSQLiteAdapter constructor signature #1426

Merged
merged 2 commits into from
Feb 15, 2024

Conversation

yu7400ki
Copy link
Contributor

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
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
Copy link
Member

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

@yu7400ki
Copy link
Contributor Author

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
Copy link
Contributor Author

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

@pilcrowOnPaper pilcrowOnPaper merged commit 0b86518 into lucia-auth:main Feb 15, 2024
@pilcrowOnPaper
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants