From 0dee67b65ba20bf0aaf957b9b46388bfd6ac9f52 Mon Sep 17 00:00:00 2001 From: yab94 Date: Thu, 10 Dec 2020 16:16:55 +0100 Subject: [PATCH] adds the postgres nulls support --- packages/crud-request/src/types/request-query.types.ts | 1 + packages/crud-typeorm/src/typeorm-crud.service.ts | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/crud-request/src/types/request-query.types.ts b/packages/crud-request/src/types/request-query.types.ts index 138e2523..8d3a3fae 100644 --- a/packages/crud-request/src/types/request-query.types.ts +++ b/packages/crud-request/src/types/request-query.types.ts @@ -18,6 +18,7 @@ export type QueryJoinArr = [string, QueryFields?]; export type QuerySort = { field: string; order: QuerySortOperator; + nulls?: string; }; export type QuerySortArr = [string, QuerySortOperator]; diff --git a/packages/crud-typeorm/src/typeorm-crud.service.ts b/packages/crud-typeorm/src/typeorm-crud.service.ts index 6bdbe6cd..9c1fb5c2 100644 --- a/packages/crud-typeorm/src/typeorm-crud.service.ts +++ b/packages/crud-typeorm/src/typeorm-crud.service.ts @@ -867,8 +867,11 @@ export class TypeOrmCrudService extends CrudService { for (let i = 0; i < sort.length; i++) { const field = this.getFieldWithAlias(sort[i].field, true); - const checkedFiled = this.checkSqlInjection(field); - params[checkedFiled] = sort[i].order; + const checkedField = this.checkSqlInjection(field); + params[checkedField] = sort[i].order; + if(this.dbName === 'postgres' && sort[i].nulls) { + params[checkedField] += " " + sort[i].nulls; + } } return params;