fix: isolate where option query (#97)
This commit is contained in:
		
							parent
							
								
									2feb8740e8
								
							
						
					
					
						commit
						dfbadfb4ce
					
				| @ -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) { | ||||||
| @ -204,12 +205,12 @@ export async function paginate<T>( | |||||||
|     const searchQuery = query.search ? `&search=${query.search}` : '' |     const searchQuery = query.search ? `&search=${query.search}` : '' | ||||||
|     const filterQuery = query.filter |     const filterQuery = query.filter | ||||||
|         ? '&' + |         ? '&' + | ||||||
|           stringify( |         stringify( | ||||||
|               mapKeys(query.filter, (_param, name) => 'filter.' + name), |             mapKeys(query.filter, (_param, name) => 'filter.' + name), | ||||||
|               '&', |             '&', | ||||||
|               '=', |             '=', | ||||||
|               { encodeURIComponent: (str) => str } |             { encodeURIComponent: (str) => str } | ||||||
|           ) |         ) | ||||||
|         : '' |         : '' | ||||||
| 
 | 
 | ||||||
|     const options = `&limit=${limit}${sortByQuery}${searchQuery}${filterQuery}` |     const options = `&limit=${limit}${sortByQuery}${searchQuery}${filterQuery}` | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user