diff --git a/src/query/parameter/sort/module.ts b/src/query/parameter/sort/module.ts index 7a6bbb6a..16a3de5a 100644 --- a/src/query/parameter/sort/module.ts +++ b/src/query/parameter/sort/module.ts @@ -1,5 +1,6 @@ import { SortDirection, SortParseOutput, parseQuerySort } from 'rapiq'; import { ObjectLiteral, SelectQueryBuilder } from 'typeorm'; +import { buildKeyWithPrefix } from '../../utils'; import { SortApplyOptions, SortApplyOutput } from './type'; // -------------------------------------------------- @@ -21,8 +22,7 @@ export function applyQuerySortParseOutput = {}; for (let i = 0; i < data.length; i++) { - const prefix : string = data[i].path ? `${data[i].path}.` : ''; - const key = `${prefix}${data[i].key}`; + const key = buildKeyWithPrefix(data[i].key, data[i].path); sort[key] = data[i].value; } @@ -64,5 +64,5 @@ export function applySort( data: unknown, options?: SortApplyOptions, ) : SortParseOutput { - return applyQuerySortParseOutput(query, parseQuerySort(data, options)); + return applyQuerySort(query, data, options); }