fix: isolate where option query (#97)

This commit is contained in:
bartosjiri ⚡ 2021-10-11 09:40:29 +02:00 committed by GitHub
parent 2feb8740e8
commit dfbadfb4ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -13,6 +13,7 @@ import {
LessThanOrEqual, LessThanOrEqual,
Not, Not,
ILike, ILike,
Brackets
} from 'typeorm' } from 'typeorm'
import { PaginateQuery } from './decorator' import { PaginateQuery } from './decorator'
import { ServiceUnavailableException } from '@nestjs/common' import { ServiceUnavailableException } from '@nestjs/common'
@ -116,7 +117,7 @@ export async function paginate<T>(
} }
if (config.where) { if (config.where) {
queryBuilder = queryBuilder.andWhere(config.where) queryBuilder = queryBuilder.andWhere(new Brackets(queryBuilder => queryBuilder.andWhere(config.where))) // Postgres fix (https://github.com/ppetzold/nestjs-paginate/pull/97)
} }
if (query.search && config.searchableColumns) { if (query.search && config.searchableColumns) {