drizzle-team / drizzle-team/drizzle-orm

[BUG]: getTableConfig primaryKeys doesn't return all primary key columns

Open
#1,285 0 comments 0 reactions 1 assignee Claimed by @Angelelz View on GitHub
bug priority
Dominant language
TypeScript
Stars
35.8k
Forks
1.6k
Avg merge
2d 7h
Merged PRs (30d)
4

Description

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

0.28.6`

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

_No response_

### Describe the Bug

When using `getTableConfig()`, the `primaryKey` attribute doesn't return any columns where the primary key was referenced in the column vs in the table.

```ts
const table = pgTable({
id: varchar("id").primaryKey()
})

const {primaryKey} = getTableConfig(table); // primaryKey is an empty array

const table2 = pgTable({
id: varchar("id")
}, (table) => {
pk: primaryKey(table.id)
})

const {primaryKey} = getTableConfig(table2); // primaryKey has 1 item
```

### Expected behavior

I expect the `primaryKey` array to have all primary key columns.

### Environment & setup

_No response_

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.