drizzle-team / drizzle-team/drizzle-orm

[FEATURE]: sql.array support to pass entire array as single parameter in prepared statement

Open
#3,768 7 comments 11 reactions 0 assignees View on GitHub
enhancement qb/crud
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

Is there something in the drizzle query builder that would allow an array to be passed in as a single parameter rather than its elements turned into individual parameters in a prepared statement? Similar to the slonik sql.array operator https://github.com/gajus/slonik?tab=readme-ov-file#sqlarray

So

```
await db.execute(sql`
SELECT * from my_table where id = ANY(${sql.array([1, 2, 3], 'int4')})
`);
```
Would produce
```
{
sql: 'SELECT * from my_table where id = ANY($1::"int4"[])',
values: [
[
1,
2,
3
]
]
}
```

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.