fix: isolate all where clauses (#130)

This commit is contained in:
bartosjiri ⚡ 2021-12-07 16:42:20 +01:00 committed by GitHub
parent 22c4b3b9e2
commit ecdf4d39b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -227,13 +227,13 @@ export async function paginate<T>(
for (const column of searchBy) { for (const column of searchBy) {
search.push({ [column]: ILike(`%${query.search}%`) }) search.push({ [column]: ILike(`%${query.search}%`) })
} }
queryBuilder = queryBuilder.andWhere(search) queryBuilder = queryBuilder.andWhere(new Brackets((queryBuilder) => queryBuilder.andWhere(search)))
} }
if (query.filter) { if (query.filter) {
const filter = parseFilter<T>(query, config) const filter = parseFilter<T>(query, config)
queryBuilder = queryBuilder.andWhere(filter) queryBuilder = queryBuilder.andWhere(new Brackets((queryBuilder) => queryBuilder.andWhere(filter)))
} }
;[items, totalItems] = await queryBuilder.getManyAndCount() ;[items, totalItems] = await queryBuilder.getManyAndCount()