From 11b605a3e7bcef5ecbe24c5a39b8a1a081a54e88 Mon Sep 17 00:00:00 2001 From: simeng-li Date: Sat, 8 Oct 2022 14:47:30 +0800 Subject: [PATCH] fix(core): fix deletePasscodeByIds bug (#2049) --- packages/core/src/queries/passcode.test.ts | 8 ++++---- packages/core/src/queries/passcode.ts | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/core/src/queries/passcode.test.ts b/packages/core/src/queries/passcode.test.ts index 9afbada45..135355a4e 100644 --- a/packages/core/src/queries/passcode.test.ts +++ b/packages/core/src/queries/passcode.test.ts @@ -133,12 +133,12 @@ describe('passcode query', () => { const ids = ['foo', 'foo2']; const expectSql = sql` delete from ${table} - where ${fields.id} in (${ids.join(',')}) + where ${fields.id} in (${sql.join(ids, sql`,`)}) `; mockQuery.mockImplementationOnce(async (sql, values) => { expectSqlAssert(sql, expectSql.sql); - expect(values).toEqual([ids.join(',')]); + expect(values).toEqual(ids); return createMockQueryResult([mockPasscode, mockPasscode]); }); @@ -150,12 +150,12 @@ describe('passcode query', () => { const ids = ['foo', 'foo2']; const expectSql = sql` delete from ${table} - where ${fields.id} in (${ids.join(',')}) + where ${fields.id} in (${sql.join(ids, sql`,`)}) `; mockQuery.mockImplementationOnce(async (sql, values) => { expectSqlAssert(sql, expectSql.sql); - expect(values).toEqual([ids.join(',')]); + expect(values).toEqual(ids); return createMockQueryResult([mockPasscode]); }); diff --git a/packages/core/src/queries/passcode.ts b/packages/core/src/queries/passcode.ts index 29f9ae69b..3dc2f0be7 100644 --- a/packages/core/src/queries/passcode.ts +++ b/packages/core/src/queries/passcode.ts @@ -56,7 +56,7 @@ export const deletePasscodeById = async (id: string) => { export const deletePasscodesByIds = async (ids: string[]) => { const { rowCount } = await envSet.pool.query(sql` delete from ${table} - where ${fields.id} in (${ids.join(',')}) + where ${fields.id} in (${sql.join(ids, sql`,`)}) `); if (rowCount !== ids.length) {