Skip to content

Commit

Permalink
🔨 add test case to see if in queries work with param arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
danyx23 committed Mar 16, 2024
1 parent 37780f9 commit aa50f14
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions db/tests/basic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,22 @@ test("knex interface", async () => {
expect(usersFromRawQuery.length).toBe(2)

// Check if in queries work as expected
const usersFromRawQueryWithInClause: Pick<DbPlainUser, "email">[] =
const usersFromRawQueryWithInClauseAsObj: Pick<DbPlainUser, "email">[] =
await knexRaw(trx, "select * from users where email in (:emails)", {
emails: [
usersFromRawQuery[0].email,
usersFromRawQuery[1].email,
],
})
expect(usersFromRawQueryWithInClause.length).toBe(2)
expect(usersFromRawQueryWithInClauseAsObj.length).toBe(2)

const usersFromRawQueryWithInClauseAsArray: Pick<
DbPlainUser,
"email"
>[] = await knexRaw(trx, "select * from users where email in ?", [
[usersFromRawQuery[0].email, usersFromRawQuery[1].email],
])
expect(usersFromRawQueryWithInClauseAsArray.length).toBe(2)

await deleteUser(trx, 2)
}, knexInstance)
Expand Down

0 comments on commit aa50f14

Please sign in to comment.