Skip to content

Commit

Permalink
adds the postgres nulls support
Browse files Browse the repository at this point in the history
  • Loading branch information
yab94 committed Dec 10, 2020
1 parent 77bb83a commit 0dee67b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/crud-request/src/types/request-query.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export type QueryJoinArr = [string, QueryFields?];
export type QuerySort = {
field: string;
order: QuerySortOperator;
nulls?: string;
};

export type QuerySortArr = [string, QuerySortOperator];
Expand Down
7 changes: 5 additions & 2 deletions packages/crud-typeorm/src/typeorm-crud.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -867,8 +867,11 @@ export class TypeOrmCrudService<T> extends CrudService<T> {

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;
Expand Down

0 comments on commit 0dee67b

Please sign in to comment.