0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-01-20 21:32:31 -05:00

fix(core): fix findUsersByIds for empty ids case (#2892)

This commit is contained in:
wangsijie 2023-01-10 13:39:15 +08:00 committed by GitHub
parent f7c08332a1
commit 8b8103132e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -161,11 +161,13 @@ export const createUserQueries = (pool: CommonQueryMethods) => {
);
const findUsersByIds = async (userIds: string[]) =>
pool.any<User>(sql`
select ${sql.join(Object.values(fields), sql`, `)}
from ${table}
where ${fields.id} in (${sql.join(userIds, sql`, `)})
`);
userIds.length > 0
? pool.any<User>(sql`
select ${sql.join(Object.values(fields), sql`, `)}
from ${table}
where ${fields.id} in (${sql.join(userIds, sql`, `)})
`)
: [];
const updateUser = buildUpdateWhereWithPool(pool)<CreateUser, User>(Users, true);