Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds the postgres nulls support #645

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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