Type Error on Drizzle orm comparison helpers like eq, and

Sample Code:
const isAlreadyInvited = await db
.select().from(InvitationTable)
.where(and(eq(InvitationTable.email, singleEmail), eq(InvitationTable.organizationId, organizationId)))
const isAlreadyInvited = await db
.select().from(InvitationTable)
.where(and(eq(InvitationTable.email, singleEmail), eq(InvitationTable.organizationId, organizationId)))
Invitation table Schema:
export const InvitationTable = pgTable(
"invitation",
{
invitationId: uuid("id").primaryKey().$defaultFn(() => createId()),
email: text("email").notNull(),
organizationId: uuid("organization_id").references(() => OrganizationTable.organizationId).notNull(),
createdAt: timestamp("created_at").defaultNow(),
updatedAt: timestamp("updated_at").defaultNow(),
}
);
export const InvitationTable = pgTable(
"invitation",
{
invitationId: uuid("id").primaryKey().$defaultFn(() => createId()),
email: text("email").notNull(),
organizationId: uuid("organization_id").references(() => OrganizationTable.organizationId).notNull(),
createdAt: timestamp("created_at").defaultNow(),
updatedAt: timestamp("updated_at").defaultNow(),
}
);
No description
7 Replies
niëmand
niëmandOP5mo ago
Error:
Argument of type 'SQL<unknown>' is not assignable to parameter of type 'SQL<unknown> | ((aliases: Record<"user", { userId: PgColumn<{ name: "user_id"; tableName: "user"; dataType: "string"; columnType: "PgText"; data: string; driverParam: string; notNull: true; hasDefault: false; ... 5 more ...; generated: undefined; }, {}, {}>; ... 4 more ...; updatedAt: PgColumn<...>; }> & Record<...>...'.
Type 'import("/home/neimand/projects/vfa/workflow-orchestrator/web/customer_portal/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected]_@_sojhkqd26sbdx6bx2a3qjvqx6u/node_modules/drizzle-orm/sql/sql").SQL<unknown>' is not assignable to type 'import("/home/neimand/projects/vfa/workflow-orchestrator/web/customer_portal/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected]_@_57qwitjd4gmw2miqapdovoxvhi/node_modules/drizzle-orm/sql/sql").SQL<unknown>'. [2345]
2. No overload matches this call.
Overload 1 of 3, '(left: Column<ColumnBaseConfig<ColumnDataType, string>, object, object>, right: unknown): SQL<unknown>', gave the following error.
Argument of type 'PgColumn<{ name: "email"; tableName: "user"; dataType: "string"; columnType: "PgText"; data: string; driverParam: string; notNull: true; hasDefault: false; isPrimaryKey: false; isAutoincrement: false; hasRuntimeDefault: false; enumValues: [...]; baseColumn: never; generated: undefined; }, {}, {}>' is not assignable to parameter of type 'Column<ColumnBaseConfig<ColumnDataType, string>, object, object>'.

Argument of type 'SQL<unknown>' is not assignable to parameter of type 'SQL<unknown> | ((aliases: Record<"user", { userId: PgColumn<{ name: "user_id"; tableName: "user"; dataType: "string"; columnType: "PgText"; data: string; driverParam: string; notNull: true; hasDefault: false; ... 5 more ...; generated: undefined; }, {}, {}>; ... 4 more ...; updatedAt: PgColumn<...>; }> & Record<...>...'.
Type 'import("/home/neimand/projects/vfa/workflow-orchestrator/web/customer_portal/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected]_@_sojhkqd26sbdx6bx2a3qjvqx6u/node_modules/drizzle-orm/sql/sql").SQL<unknown>' is not assignable to type 'import("/home/neimand/projects/vfa/workflow-orchestrator/web/customer_portal/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected]_@_57qwitjd4gmw2miqapdovoxvhi/node_modules/drizzle-orm/sql/sql").SQL<unknown>'. [2345]
2. No overload matches this call.
Overload 1 of 3, '(left: Column<ColumnBaseConfig<ColumnDataType, string>, object, object>, right: unknown): SQL<unknown>', gave the following error.
Argument of type 'PgColumn<{ name: "email"; tableName: "user"; dataType: "string"; columnType: "PgText"; data: string; driverParam: string; notNull: true; hasDefault: false; isPrimaryKey: false; isAutoincrement: false; hasRuntimeDefault: false; enumValues: [...]; baseColumn: never; generated: undefined; }, {}, {}>' is not assignable to parameter of type 'Column<ColumnBaseConfig<ColumnDataType, string>, object, object>'.

Types of property 'table' are incompatible.
Type 'PgTable<TableConfig>' is not assignable to type 'Table<TableConfig<Column<any, object, object>>>'.
Overload 2 of 3, '(left: Aliased<string>, right: string | SQLWrapper): SQL<unknown>', gave the following error.
Argument of type 'PgColumn<{ name: "email"; tableName: "user"; dataType: "string"; columnType: "PgText"; data: string; driverParam: string; notNull: true; hasDefault: false; isPrimaryKey: false; isAutoincrement: false; hasRuntimeDefault: false; enumValues: [...]; baseColumn: never; generated: undefined; }, {}, {}>' is not assignable to parameter of type 'Aliased<string>'.
Type 'PgColumn<{ name: "email"; tableName: "user"; dataType: "string"; columnType: "PgText"; data: string; driverParam: string; notNull: true; hasDefault: false; isPrimaryKey: false; isAutoincrement: false; hasRuntimeDefault: false; enumValues: [...]; baseColumn: never; generated: undefined; }, {}, {}>' is missing the following properties from type 'Aliased<string>': sql, fieldAlias
Overload 3 of 3, '(left: SQLWrapper, right: unknown): SQL<unknown>', gave the following error.
Argument of type 'PgColumn<{ name: "email"; tableName: "user"; dataType: "string"; columnType: "PgText"; data: string; driverParam: string; notNull: true; hasDefault: false; isPrimaryKey: false; isAutoincrement: false; hasRuntimeDefault: false; enumValues: [...]; baseColumn: never; generated: undefined; }, {}, {}>' is not assignable to parameter of type 'SQLWrapper'.
Types of property 'getSQL' are incompatible.
Types of property 'table' are incompatible.
Type 'PgTable<TableConfig>' is not assignable to type 'Table<TableConfig<Column<any, object, object>>>'.
Overload 2 of 3, '(left: Aliased<string>, right: string | SQLWrapper): SQL<unknown>', gave the following error.
Argument of type 'PgColumn<{ name: "email"; tableName: "user"; dataType: "string"; columnType: "PgText"; data: string; driverParam: string; notNull: true; hasDefault: false; isPrimaryKey: false; isAutoincrement: false; hasRuntimeDefault: false; enumValues: [...]; baseColumn: never; generated: undefined; }, {}, {}>' is not assignable to parameter of type 'Aliased<string>'.
Type 'PgColumn<{ name: "email"; tableName: "user"; dataType: "string"; columnType: "PgText"; data: string; driverParam: string; notNull: true; hasDefault: false; isPrimaryKey: false; isAutoincrement: false; hasRuntimeDefault: false; enumValues: [...]; baseColumn: never; generated: undefined; }, {}, {}>' is missing the following properties from type 'Aliased<string>': sql, fieldAlias
Overload 3 of 3, '(left: SQLWrapper, right: unknown): SQL<unknown>', gave the following error.
Argument of type 'PgColumn<{ name: "email"; tableName: "user"; dataType: "string"; columnType: "PgText"; data: string; driverParam: string; notNull: true; hasDefault: false; isPrimaryKey: false; isAutoincrement: false; hasRuntimeDefault: false; enumValues: [...]; baseColumn: never; generated: undefined; }, {}, {}>' is not assignable to parameter of type 'SQLWrapper'.
Types of property 'getSQL' are incompatible.
Type '() => import("/home/neimand/projects/vfa/workflow-orchestrator/web/customer_portal/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected]_@_57qwitjd4gmw2miqapdovoxvhi/node_modules/drizzle-orm/sql/sql").SQL<unknown>' is not assignable to type '() => import("/home/neimand/projects/vfa/workflow-orchestrator/web/customer_portal/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected]_@_sojhkqd26sbdx6bx2a3qjvqx6u/node_modules/drizzle-orm/sql/sql").SQL<unknown>'
Type '() => import("/home/neimand/projects/vfa/workflow-orchestrator/web/customer_portal/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected]_@_57qwitjd4gmw2miqapdovoxvhi/node_modules/drizzle-orm/sql/sql").SQL<unknown>' is not assignable to type '() => import("/home/neimand/projects/vfa/workflow-orchestrator/web/customer_portal/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected]_@_sojhkqd26sbdx6bx2a3qjvqx6u/node_modules/drizzle-orm/sql/sql").SQL<unknown>'
Although everything is working fine without any issues, I keep getting this type issue wherever I use and or eq. It was not like this before.
Mario564
Mario5644mo ago
Hello there. Are you using a monorepo? I've see this kind of issue before in those environments
niëmand
niëmandOP4mo ago
yes, turbo
Mario564
Mario5644mo ago
CC: @Andrii Sherman
niëmand
niëmandOP4mo ago
It is not a major issue but it’s annoying seeing all those red errors especially in a big codebase.
rphlmr ⚡
rphlmr ⚡4mo ago
Hum yep it’s a mix of different drizzle version. In my monorepo I set drizzle as peer dependencies with a range (on packages)
No description
niëmand
niëmandOP4mo ago
Sorry for not noticing it. I have made both the repos with same drizzle version and verything is fine now.
Want results from more Discord servers?
Add your server