drizzle-team / drizzle-team/drizzle-orm

[BUG]: Partial Insert returning expected 0 arguments

Open
#2,496 10 comments 1 reaction 1 assignee Claimed by @AndriiSherman View on GitHub
bug db/postgres priority qb/crud
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.30.10

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

0.21.4

### Describe the Bug

I have the following code snippet:
```ts
const recordId = await db
.insert(organizationsTable)
.values({ clerkId: 'whatever-id' })
.returning({ id: organizationsTable.id });
```

After an insert, I'm trying to return a value with [partial insert returning](https://orm.drizzle.team/docs/insert#insert-returning). However, TS is complaining that `returning` "Expected 0 arguments, but got 1.":

![CleanShot 2024-06-12 at 17 41 02@2x](https://github.com/drizzle-team/drizzle-orm/assets/11754473/cdeef7e7-5072-4a98-92b4-0568b9aef52b)

Removing the partial return and simply returning the whole thing does not complain at all and works as expected:
```ts
const recordId = await db
.insert(organizationsTable)
.values({ clerkId: 'whatever-id' })
.returning();
```

I initially thought it was a problem with VSCode so I tried to restart TS server, make sure that it matches the project's TS version and so on, but it also fails when I do the build step.

Navigating to source I can see that both function definitions exist:
```ts
returning(): PgInsertWithout, TDynamic, 'returning'>;
returning(fields: TSelectedFields): PgInsert...
```

### Expected behavior

It should allow me to pass an argument to select the fields I want to return.

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