From c2e31c38360700f327a5cf75262300d35a1ffdd4 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Fri, 14 Jun 2024 22:00:48 +0530 Subject: [PATCH] fix: apply sort after parsing list data Signed-off-by: Pranav C --- packages/nocodb/src/cache/CacheMgr.ts | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/packages/nocodb/src/cache/CacheMgr.ts b/packages/nocodb/src/cache/CacheMgr.ts index f615cc93c7..de727f4183 100644 --- a/packages/nocodb/src/cache/CacheMgr.ts +++ b/packages/nocodb/src/cache/CacheMgr.ts @@ -332,6 +332,17 @@ export default abstract class CacheMgr { ); } } + const list = values.map((res) => { + try { + const o = JSON.parse(res); + if (typeof o === 'object') { + return o.value; + } + } catch (e) { + return res; + } + return res; + }); // Check if orderBy parameter is provided and valid if (orderBy?.key) { @@ -342,7 +353,7 @@ export default abstract class CacheMgr { const orderMultiplier = dir === 'desc' ? -1 : 1; // Sort the values array based on the specified property - values.sort((a, b) => { + list.sort((a, b) => { // Get the property values from a and b const aValue = a?.[key]; const bValue = b?.[key]; @@ -362,17 +373,7 @@ export default abstract class CacheMgr { } return { - list: values.map((res) => { - try { - const o = JSON.parse(res); - if (typeof o === 'object') { - return o.value; - } - } catch (e) { - return res; - } - return res; - }), + list, isNoneList, }; }