drizzle-team / drizzle-team/drizzle-orm

[BUG]: inArray/notInArray empty arrays do not work with SQL Server

Open
#5,632 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
TypeScript
Stars
35.8k
Forks
1.6k
Avg merge
2d 7h
Merged PRs (30d)
4

Description

### Report hasn't been filed before.

- [x] I have verified that the bug I'm about to report hasn't been filed before.

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

1.0.0.beta-20

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

1.0.0.beta-20

### Other packages

_No response_

### Describe the Bug

When using `inArray` and `notInArray` with empty arrays and the mssql driver, the sql generated uses the `true`/`false` keywords, which don't exist in tsql.

```ts
const arr = []

db.select().from(table).where(inArray(column, arr))
db.select().from(table).where(notInArray(column, arr))
```
and the generated query would look like
```sql
SELECT * FROM table WHERE false;
SELECT * FROM table WHERE true;
```
The fix would be to use something more standard, like `1=0` for `false` and `1=1` for `true`.

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.