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

[Bug]: incompatible types with generatedAlwaysAsIdentity #1663

Open
araujogui opened this issue Aug 15, 2024 · 0 comments
Open

[Bug]: incompatible types with generatedAlwaysAsIdentity #1663

araujogui opened this issue Aug 15, 2024 · 0 comments
Labels
bug Something ain't right...

Comments

@araujogui
Copy link

Package

​@lucia-auth/session-drizzle

Describe the bug

When I try to use the generatedAlwaysAsIdentity() function on the id column from users, TypeScript presents the following type compatibility error

 The types of '_.inferInsert' are incompatible between these types.
    Type '{ name: string; }' has no properties in common with type '{ id?: number | undefined; 

Example code:

const userTable = pgTable("users", {
  id: integer("id").primaryKey().generatedAlwaysAsIdentity(),
  name: text("name").notNull(),
});

const adapter = new DrizzlePostgreSQLAdapter(db, sessionTable, userTable);

Apparently, the type PgTableWithColumns from Drizzle enforces that the id property should exist on $inferInsert type as well, even though it's not necessary since we don't insert users via Lucia.

Workaround:

const adapter = new DrizzlePostgreSQLAdapter(
  db,
  sessionTable,
  userTable as PostgreSQLUserTable,
);
@araujogui araujogui added the bug Something ain't right... label Aug 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something ain't right...
Projects
None yet
Development

No branches or pull requests

1 participant