drizzle-team / drizzle-team/drizzle-orm

[DOCS]: Clarify behavior of onConflictDoX when inserting multiple values at once

Open
#4,065 0 comments 0 reactions 0 assignees View on GitHub
docs docs/undocumented qb/crud
Dominant language
TypeScript
Stars
35.8k
Forks
1.6k
Avg merge
2d 7h
Merged PRs (30d)
4

Description

### Enhancement hasn't been filed before.

- [x] I have verified this enhancement I'm about to request hasn't been suggested before.

### Describe the enhancement you want to request

The docs currently suggest that the `onConflictDoNothing` method "cancels the insert" when a conflict is found - but the docs only include examples for single insert - not multiple value inserts.

Does this mean that if I am inserting a batch of 100 records and one of them has a conflict, the entire insert (of all 100 records) is canceled? Or do the other 99 still get inserted?

E.g.
```ts
await db.insert(table)
.values(arrayOf100ValuesWithOneConflict)
.onConflictDoNothing()

// Do 99 or 0 records get inserted? - Docs should mention this
```

I suggest updating the docs to clarify what the behavior is.

Edit: Based on quick, rough testing, it appears that the entire batch of inserts is cancelled if there are any conflicts within the batch - would be nice to have this explicitly stated in the docs.

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.