drizzle-team / drizzle-team/drizzle-orm
[FEATURE]: native support for postgres unnest
- Dominant language
- TypeScript
- Stars
- 35.8k
- Forks
- 1.6k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 4
Description
### Feature hasn't been suggested before.
- [x] I have verified this feature I'm about to request hasn't been suggested before.
### Describe the enhancement you want to request
Doing batch inserts via `insert` is painful due to limitations in postgres.
I tried improving the situation here: https://github.com/drizzle-team/drizzle-orm/pull/5400, but eventually it boils down to this pattern being quite limited.
The alternatives are `copy`, which has it's own limitations and select `unnest`.
Working with unnest from drizzle is a pain though, as you basically need to write raw sql and opt out drizzle i guess.
```
INSERT INTO balance_deltas ("user", delta)
SELECT * FROM unnest(
${sql.param(users)}::text[],
${sql.param(deltas)}::numeric(78,0)[]
)
ON CONFLICT ("user")
DO UPDATE SET delta = balance_deltas.delta + excluded.delta
```
I feel like it would be great to have some better native integration, like `db.insert().unnestValues()` or similar.
Contributor guide
Assessment
This issue has not been assessed yet.