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
FroeMic opened this issue
Jul 31, 2024
· 4 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.
After running npm create t3-app@latest the NextAuth DrizzleAdapter throws a Typescript error in /src/server/auth.ts (see reproduction example.
It seems that the schemas generated by drizzle are not compatible with the ones the adapter expects. Some properties expected by the column type of the adapter are not provided by the schemas generated by drizzle.
Type 'PgTableWithColumns<{
name: "user";
schema: undefined;
columns: {
id: PgColumn<{
name: "id";
tableName: "user";
dataType: "string";
columnType: "PgText";
data: string;
driverParam: string;
notNull: true;
hasDefault: true;
enumValues: [...];
baseColumn: never;
}, {}, {}>;
name: PgColumn<...>;
email: PgColumn<...>;
ema...
}
}>' is not assignable to type 'DefaultPostgresUsersTable'.
Type 'PgTableWithColumns<{
name: "user";
schema: undefined;
columns: {
id: PgColumn<{
name: "id";
tableName: "user";
dataType: "string";
columnType: "PgText";
data: string;
driverParam: string;
notNull: true;
hasDefault: true;
enumValues: [...];
baseColumn: never;
}, {}, {}>;
name: PgColumn<...>;
email: PgColumn<...>;
ema...
}
}>' is not assignable to type 'PgTable<{
name: string;
columns: {
id: DefaultPostgresColumn<{
columnType: "PgVarchar" | "PgText" | "PgUUID";
isPrimaryKey: true;
data: string;
notNull: true;
dataType: "string";
}>;
name: DefaultPostgresColumn<...>;
email: DefaultPostgresColumn<...>;
emailVerified: DefaultPostgresColumn<...>;
image: DefaultPostgres...
}>'.
The types of '_.config.columns.id' are incompatible between these types.
Type 'PgColumn<{
name: "id";
tableName: "user";
dataType: "string";
columnType: "PgText";
data: string;
driverParam: string;
notNull: true;
hasDefault: true;
enumValues: [string, ...string[]];
baseColumn: never;
}, {}, {}>' is not assignable to type 'DefaultPostgresColumn<{
columnType: "PgVarchar" | "PgText" | "PgUUID";
isPrimaryKey: true;
data: string;
notNull: true;
dataType: "string";
}>'.
Type '{
name: "id";
tableName: "user";
dataType: "string";
columnType: "PgText";
data: string;
driverParam: string;
notNull: true;
hasDefault: true;
enumValues: [string, ...string[]];
baseColumn: never;
}' is missing the following properties from type '{
name: string;
isAutoincrement: boolean;
isPrimaryKey: true;
hasRuntimeDefault: boolean;
generated: any;
columnType: "PgVarchar" | "PgText" | "PgUUID";
data: string;
driverParam: string | number | boolean;
... 4 more ...;
tableName: string;
}':
isAutoincrement,
isPrimaryKey,
hasRuntimeDefault,
generated
What does that mean? The DefaultPostgresColumn type definition in adapter-drizzle/src/lib/pg.ts expects for each column values (isAutoincrement, isPrimaryKey, hasRuntimeDefault, generated), that the schema generated by pgTable doesn't have.
How to reproduce
You should be able to reproduce the error by running npm create t3-app@latest with the above mentioned options and then opening /src/server/auth.ts and /src/server/db/schema.ts
TypeScript
Tailwind
tRCP
NextAuth.js
Drizzle
App Router
PosgreSQL
Git (yes)
npm install (yes)
alias: ~/
Expected behavior
The Table / Column Definitions generated by Drizzle are compatible with the Adapter.
The text was updated successfully, but these errors were encountered:
FroeMic
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
Jul 31, 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
Reproduction URL
https://github.com/FroeMic/t3-auth-test
Describe the issue
After running
npm create t3-app@latest
the NextAuth DrizzleAdapter throws a Typescript error in/src/server/auth.ts
(see reproduction example.It seems that the schemas generated by drizzle are not compatible with the ones the adapter expects. Some properties expected by the column type of the adapter are not provided by the schemas generated by drizzle.
Using the first example from the PostgreSQL schema.ts example from https://authjs.dev/getting-started/adapters/drizzle#schemas:
Schema
Typescript Error (formatted)
What does that mean? The
DefaultPostgresColumn
type definition in adapter-drizzle/src/lib/pg.ts expects for each column values (isAutoincrement
,isPrimaryKey
,hasRuntimeDefault
,generated
), that the schema generated bypgTable
doesn't have.How to reproduce
You should be able to reproduce the error by running
npm create t3-app@latest
with the above mentioned options and then opening/src/server/auth.ts
and/src/server/db/schema.ts
Expected behavior
The Table / Column Definitions generated by Drizzle are compatible with the Adapter.
The text was updated successfully, but these errors were encountered: