Skip to content

[BUG]: Left Join PgColumn Incompatible #4535

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

Open
1 task done
oRafael07 opened this issue May 20, 2025 · 4 comments
Open
1 task done

[BUG]: Left Join PgColumn Incompatible #4535

oRafael07 opened this issue May 20, 2025 · 4 comments
Labels
bug Something isn't working

Comments

@oRafael07
Copy link

Report hasn't been filed before.

  • 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

Image

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>'.
@oRafael07 oRafael07 added the bug Something isn't working label May 20, 2025
@ThomasAunvik
Copy link

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>'.

@ThomasAunvik
Copy link

Bug seems to be present since 0.43.0

Downgrading to 0.42.0 fixes the issue.

@ThomasAunvik
Copy link

Duplicate of issue #4457

@ESchouten
Copy link

Downgrading does not seem to fix the issue for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants