[BUG]: Left Join PgColumn Incompatible
Report hasn't been filed before.
- [x] I have verified that the bug I'm about to report hasn't been filed before.
What version of drizzle-orm are you using?
0.43.1
What version of drizzle-kit are you using?
0.31.1
Other packages
No response
Describe the Bug
When I do the left Join on my accounts table, the typoscript complains about incompatibility
My tables:
export const providerEnum = pgEnum('providers', ['google'])
const account = pgTable('accounts', {
id: uuid('id').primaryKey().notNull().defaultRandom(),
userId: uuid('user_id')
.notNull()
.references(() => users.id),
provider: providerEnum().notNull(),
providerId: text().notNull().unique(),
})
const users = pgTable('users', {
id: uuid('id').primaryKey().defaultRandom(),
name: text('name').notNull(),
username: text('username').notNull().unique(),
email: text('email').notNull().unique(),
password: text('password'),
createdAt: timestamp('created_at', { withTimezone: true })
.defaultNow()
.notNull(),
updatedAt: timestamp('updated_at', { withTimezone: true }).$onUpdateFn(
() => new Date()
),
})
My code:
const [userExists] = await db
.select()
.from(users)
.where(eq(users.email, email))
.innerJoin(account, eq(users.id, account.id))
Error:
Argument of type 'PgTableWithColumns<{ name: "accounts"; schema: undefined; columns: { id: PgColumn<{ name: "id"; tableName: "accounts"; dataType: "string"; columnType: "PgUUID"; data: string; driverParam: string; notNull: true; hasDefault: true; ... 6 more ...; generated: undefined; }, {}, {}>; userId: PgColumn<...>; provider: PgCol...' is not assignable to parameter of type 'SQL<unknown> | Subquery<string, Record<string, unknown>> | PgViewBase<string, boolean, ColumnsSelection> | PgTable<TableConfig>'.
Type 'PgTableWithColumns<{ name: "accounts"; schema: undefined; columns: { id: PgColumn<{ name: "id"; tableName: "accounts"; dataType: "string"; columnType: "PgUUID"; data: string; driverParam: string; notNull: true; hasDefault: true; ... 6 more ...; generated: undefined; }, {}, {}>; userId: PgColumn<...>; provider: PgCol...' is not assignable to type 'PgTable<TableConfig>'.
The types of '_.config.columns' are incompatible between these types.
Type '{ id: PgColumn<{ name: "id"; tableName: "accounts"; dataType: "string"; columnType: "PgUUID"; data: string; driverParam: string; notNull: true; hasDefault: true; isPrimaryKey: true; isAutoincrement: false; ... 4 more ...; generated: undefined; }, {}, {}>; userId: PgColumn<...>; provider: PgColumn<...>; providerId: P...' is not assignable to type 'Record<string, PgColumn<ColumnBaseConfig<ColumnDataType, string>, {}, {}>>'.
Property 'id' is incompatible with index signature.
Type 'PgColumn<{ name: "id"; tableName: "accounts"; dataType: "string"; columnType: "PgUUID"; data: string; driverParam: string; notNull: true; hasDefault: true; isPrimaryKey: true; isAutoincrement: false; ... 4 more ...; generated: undefined; }, {}, {}>' is not assignable to type 'PgColumn<ColumnBaseConfig<ColumnDataType, string>, {}, {}>'.
The types of 'table._.config.columns' are incompatible between these types.
Type 'Record<string, import("d:/Projects/backend/santuario-sao-jose-operatio-backend/node_modules/drizzle-orm/pg-core/columns/common").PgColumn<import("d:/Projects/backend/santuario-sao-jose-operatio-backend/node_modules/drizzle-orm/column").ColumnBaseConfig<import("d:/Projects/backend/santuario-sao-jose-operatio-backend/...' is not assignable to type 'Record<string, import("d:/Projects/backend/santuario-sao-jose-operatio-backend/node_modules/drizzle-orm/pg-core/columns/common", { with: { "resolution-mode": "import" } }).PgColumn<import("d:/Projects/backend/santuario-sao-jose-operatio-backend/node_modules/drizzle-orm/column", { with: { "resolution-mode": "import" ...'.
'string' index signatures are incompatible.
Type 'import("d:/Projects/backend/santuario-sao-jose-operatio-backend/node_modules/drizzle-orm/pg-core/columns/common").PgColumn<import("d:/Projects/backend/santuario-sao-jose-operatio-backend/node_modules/drizzle-orm/column").ColumnBaseConfig<import("d:/Projects/backend/santuario-sao-jose-operatio-backend/node_modules/dr...' is not assignable to type 'import("d:/Projects/backend/santuario-sao-jose-operatio-backend/node_modules/drizzle-orm/pg-core/columns/common", { with: { "resolution-mode": "import" } }).PgColumn<import("d:/Projects/backend/santuario-sao-jose-operatio-backend/node_modules/drizzle-orm/column", { with: { "resolution-mode": "import" } }).ColumnBase...'.
Property 'config' is protected but type 'Column<T, TRuntimeConfig, TTypeConfig>' is not a class derived from 'Column<T, TRuntimeConfig, TTypeConfig>'.
Having the same issue. I use Turborepo, and i get errors like this in my packages/db folder but not in one of my apps/myapp folder. And only one single app in my turborepo has that problem aswell.
Argument of type 'PgTableWithColumns<{ name: "user_organization_group"; schema: "app"; columns: { orgId: PgColumn<{ name: "org_id"; tableName: "user_organization_group"; dataType: "string"; columnType: "PgUUID"; data: string; driverParam: string; ... 8 more ...; generated: undefined; }, {}, {}>; userId: PgColumn<...>; groupId: PgColu...' is not assignable to parameter of type 'SQL<unknown> | Subquery<string, Record<string, unknown>> | PgViewBase<string, boolean, ColumnsSelection> | PgTable<TableConfig>'.
Type 'PgTableWithColumns<{ name: "user_organization_group"; schema: "app"; columns: { orgId: PgColumn<{ name: "org_id"; tableName: "user_organization_group"; dataType: "string"; columnType: "PgUUID"; data: string; driverParam: string; ... 8 more ...; generated: undefined; }, {}, {}>; userId: PgColumn<...>; groupId: PgColu...' is not assignable to type 'PgTable<TableConfig>'.
The types of '_.config.columns' are incompatible between these types.
Type '{ orgId: PgColumn<{ name: "org_id"; tableName: "user_organization_group"; dataType: "string"; columnType: "PgUUID"; data: string; driverParam: string; notNull: true; hasDefault: false; isPrimaryKey: false; ... 5 more ...; generated: undefined; }, {}, {}>; userId: PgColumn<...>; groupId: PgColumn<...>; addedBy: PgCol...' is not assignable to type 'Record<string, PgColumn<ColumnBaseConfig<ColumnDataType, string>, {}, {}>>'.
Property 'orgId' is incompatible with index signature.
Type 'PgColumn<{ name: "org_id"; tableName: "user_organization_group"; dataType: "string"; columnType: "PgUUID"; data: string; driverParam: string; notNull: true; hasDefault: false; isPrimaryKey: false; ... 5 more ...; generated: undefined; }, {}, {}>' is not assignable to type 'PgColumn<ColumnBaseConfig<ColumnDataType, string>, {}, {}>'.
The types of 'table._.config.columns' are incompatible between these types.
Type 'Record<string, import("/home/thaun/Documents/Projects/case-frontend/node_modules/drizzle-orm/pg-core/columns/common").PgColumn<import("/home/thaun/Documents/Projects/case-frontend/node_modules/drizzle-orm/column").ColumnBaseConfig<import("/home/thaun/Documents/Projects/case-frontend/node_modules/drizzle-orm/column-b...' is not assignable to type 'Record<string, import("/home/thaun/Documents/Projects/case-frontend/node_modules/drizzle-orm/pg-core/columns/common", { with: { "resolution-mode": "import" } }).PgColumn<import("/home/thaun/Documents/Projects/case-frontend/node_modules/drizzle-orm/column", { with: { "resolution-mode": "import" } }).ColumnBaseConfig<...'.
'string' index signatures are incompatible.
Type 'import("/home/thaun/Documents/Projects/case-frontend/node_modules/drizzle-orm/pg-core/columns/common").PgColumn<import("/home/thaun/Documents/Projects/case-frontend/node_modules/drizzle-orm/column").ColumnBaseConfig<import("/home/thaun/Documents/Projects/case-frontend/node_modules/drizzle-orm/column-builder").Column...' is not assignable to type 'import("/home/thaun/Documents/Projects/case-frontend/node_modules/drizzle-orm/pg-core/columns/common", { with: { "resolution-mode": "import" } }).PgColumn<import("/home/thaun/Documents/Projects/case-frontend/node_modules/drizzle-orm/column", { with: { "resolution-mode": "import" } }).ColumnBaseConfig<import("/home/t...'.
Property 'config' is protected but type 'Column<T, TRuntimeConfig, TTypeConfig>' is not a class derived from 'Column<T, TRuntimeConfig, TTypeConfig>'.
Duplicate of issue https://github.com/drizzle-team/drizzle-orm/issues/4457
Downgrading does not seem to fix the issue for me
Same issue here, in a Nx monorepo.
@oRafael07 Were you able to find a solution for this, thanks.
@oRafael07 Were you able to find a solution for this, thanks.
Yeah, like said before, downgrade to 0.42, hasn't that worked for you?
@oRafael07 do you have a monorepo setup?
reproduced, fixing this issue at least trying
@AndriiSherman I have currently downgraded to version 0.42.x
The problem persists in version 0.44.1. The version 0.42.0 is a stable version for this problem.
The problem persists in version
0.44.1. The version0.42.0is a stable version for this problem.
Yeah I can confirm this, it also doesn't matter if you're running a monorepo or not. I checked my nom packages to see if there were any version mismatches being pulled in somewhere through drizzle zod or something, but that wasn't the case. It's purely 0.42.0 => that's causing this.
should be fixed in [email protected]
Deploy is in progress, ~20 mins to go live
fixed in [email protected]