From dc7f713899032eafbda19de9dfeba936c020a1d3 Mon Sep 17 00:00:00 2001 From: tada5hi Date: Thu, 20 Oct 2022 15:38:41 +0200 Subject: [PATCH] fix: apply-sort should rely on apply-query-sort --- src/query/parameter/sort/module.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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); }