drizzle-team / drizzle-team/drizzle-orm

[BUG]: Drizzle can no longer accept cockroach tables in a postgres `drizzle()` instance

Open
#5,280 1 comment 1 reaction 0 assignees View on GitHub
1.0.0-beta.* enhancement
Dominant language
TypeScript
Stars
35.8k
Forks
1.6k
Avg merge
2d 7h
Merged PRs (30d)
4

Description

### 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?

1.0.0-beta.9-e89174b

### What version of `drizzle-kit` are you using?

1.0.0-beta.9-e89174b

### Other packages

_No response_

### Describe the Bug

These three snippets of code in my project
```ts
export const db = drizzle(process.env.DATABASE_URL!, { relations });
```

Because I am using cockroachdb, I am going to declare a cockroach table.
```js
export const users = cockroachTable("users", {
email: varchar("email", { length: 254 }).primaryKey(),
name: varchar("name", { length: 256 }).notNull(),
accountType: accountTypes("account_type").notNull().default("GUEST"),
avatar: varchar("avatar", { length: 256 }),

createdAt: timestamp("created_at", { withTimezone: true }),
updatedAt: timestamp("updated_at", { withTimezone: true })
.defaultNow()
.$onUpdate(() => sql`CURRENT_TIMESTAMP`),
});
```

and then finally using it

```js
await db.update(users).set(input).where(eq(users.email, email));
```

However, upon updating from 1.0.0-beta.6-ea4d663 to 1.0.0-beta.9-e89174b,

I no longer can use cockroachdb table in a postgres db instance.

```
await db.update(users).set(input).where(eq(users.email, email));
^^^^^
Argument of type 'CockroachTableWithColumns<{ name: "users"; schema: undefined; columns: { email: CockroachColumn<{ name: string; tableName: "users"; dataType: "string"; data: string; driverParam: string; notNull: true; hasDefault: false; isPrimaryKey: true; ... 5 more ...; generated: undefined; }, {}>; ... 4 more ...; updatedAt: Coc...' is not assignable to parameter of type 'PgTable'.
Types of property '_' are incompatible.
Type 'TableTypeConfig<{ name: "users"; schema: undefined; columns: { email: CockroachColumn<{ name: string; tableName: "users"; dataType: "string"; data: string; driverParam: string; notNull: true; hasDefault: false; isPrimaryKey: true; ... 5 more ...; generated: undefined; }, {}>; ... 4 more ...; updatedAt: CockroachColu...' is not assignable to type 'TableTypeConfig'.
Type '{ name: "users"; schema: undefined; columns: { email: CockroachColumn<{ name: string; tableName: "users"; dataType: "string"; data: string; driverParam: string; notNull: true; hasDefault: false; isPrimaryKey: true; ... 5 more ...; generated: undefined; }, {}>; ... 4 more ...; updatedAt: CockroachColumn<...>; }; dial...' is not assignable to type 'TableConfig'.
Types of property 'columns' are incompatible.
Type '{ email: CockroachColumn<{ name: string; tableName: "users"; dataType: "string"; data: string; driverParam: string; notNull: true; hasDefault: false; isPrimaryKey: true; isAutoincrement: false; hasRuntimeDefault: false; enumValues: [...]; baseColumn: never; identity: undefined; generated: undefined; }, {}>; ... 4 mo...' is not assignable to type 'PgColumns'.
Property 'email' is incompatible with index signature.
Property 'dimensions' is missing in type 'CockroachColumn<{ name: string; tableName: "users"; dataType: "string"; data: string; driverParam: string; notNull: true; hasDefault: false; isPrimaryKey: true; isAutoincrement: false; hasRuntimeDefault: false; enumValues: [...]; baseColumn: never; identity: undefined; generated: undefined; }, {}>' but required in type 'PgColumn, {}>'.
```

I'm using the postgres `drizzle()` because the cockroach one does not support `db.query` and CockroachDB themselves have said "Most importantly, [CockroachDB is compatible with PostgreSQL](https://www.cockroachlabs.com/blog/postgresql-compatible-database-cockroachdb/)"

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.