drizzle-team / drizzle-orm

Headless TypeScript ORM with a head. Runs on Node, Bun and Deno. Lives on the Edge and yes, it's a JavaScript ORM too 😅
https://orm.drizzle.team
Apache License 2.0
23.56k stars 579 forks source link

[BUG]: drizzle multi project schema with kysely #2752

Open smhmayboudi opened 1 month ago

smhmayboudi commented 1 month ago

What version of drizzle-orm are you using?

0.32.1

What version of drizzle-kit are you using?

0.23.1

Describe the Bug

I am using https://github.com/drizzle-team/drizzle-orm/tree/main/drizzle-orm/src/kysely as a connector between drizzle and kysely. When I define my custom mysqlTableCreator, the drizzle is not working properly.

const mysqlTable = mysqlTableCreator((name) => `${name.toUpperCase()}`);

export const user = mysqlTable(
  "user",
  {
    age: varchar("age", { length: 128 }).notNull(),
    email: varchar("email", { length: 128 }).notNull(),
    id: varchar("id", { length: 128 }).$defaultFn(() => createId()),
    name: varchar("name", { length: 128 }).notNull(),
  },
  (user) => ({
    userEmailIndex: unique("USER_EMAIL_INDEX").on(user.email),
    userIdPK: primaryKey({ name: "USER_ID_PK", columns: [user.id] }),
  }),
);
kysely:error: Error: Table 'hono-poc.user' doesn't exist
...

Expected behavior

The table name should 'USER' instead of 'hono-poc.user'.

Environment & setup

node -v: v20.16.0 pnpm -v: 9.6.0 os: macOS 14.5 (23F79)