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
21.44k stars 484 forks source link

[BUG]: drizzle-kit generate creates broken SQL for postgres when creating compound primary key #2514

Open beermonsterdota opened 2 weeks ago

beermonsterdota commented 2 weeks ago

What version of drizzle-orm are you using?

0.31.2

What version of drizzle-kit are you using?

0.22.7

Describe the Bug

Same issue as #2423 when creating compound primary key with camelCase in one of columns name

export const accounts = pgTable(
  'account',
  {
    userId: text('userId'),
    providerAccountId: text('providerAccountId').notNull()
  },
  (account) => ({
    compoundKey: primaryKey({
      columns: [account.provider, account.providerAccountId],
      name: 'compound_pk',
    }),
  })
)

will create SQL to migrate that will throw error during migration ALTER TABLE "account" ADD CONSTRAINT compound_pk PRIMARY KEY(provider,providerAccountId);

Expected behavior

Should have quotes around "camelCase" field ALTER TABLE "account" ADD CONSTRAINT compound_pk PRIMARY KEY(provider,"providerAccountId");

Environment & setup

No response