Skip to content

Commit

Permalink
When passed an empty array inArray now returns false and notInArray n…
Browse files Browse the repository at this point in the history
…ow return true instead of throwing
  • Loading branch information
Angelelz committed Dec 17, 2023
1 parent 6223ca0 commit 661a4ee
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drizzle-orm/src/sql/expressions/conditions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ export function inArray(
): SQL {
if (Array.isArray(values)) {
if (values.length === 0) {
throw new Error('inArray requires at least one value');
return sql`false`;
}
return sql`${column} in ${values.map((v) => bindIfParam(v, column))}`;
}
Expand Down Expand Up @@ -335,7 +335,7 @@ export function notInArray(
): SQL {
if (Array.isArray(values)) {
if (values.length === 0) {
throw new Error('notInArray requires at least one value');
return sql`true`;
}
return sql`${column} not in ${values.map((v) => bindIfParam(v, column))}`;
}
Expand Down

0 comments on commit 661a4ee

Please sign in to comment.