From 2792f68eaa2454255fe2bbca501b2deef753df95 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Fri, 10 Nov 2023 13:01:46 +0530 Subject: [PATCH] fix: check view/id defined or not before getting sort list based on viewId --- packages/nocodb/src/db/BaseModelSqlv2.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/nocodb/src/db/BaseModelSqlv2.ts b/packages/nocodb/src/db/BaseModelSqlv2.ts index 279aef7868..58a987dc89 100644 --- a/packages/nocodb/src/db/BaseModelSqlv2.ts +++ b/packages/nocodb/src/db/BaseModelSqlv2.ts @@ -657,10 +657,13 @@ class BaseModelSqlv2 { qb, ); - if (!sorts) - sorts = args.sortArr?.length - ? args.sortArr - : await Sort.list({ viewId: this.viewId }); + if (!sorts) { + if (args.sortArr?.length) { + sorts = args.sortArr; + } else if (this.viewId) { + sorts = await Sort.list({ viewId: this.viewId }); + } + } // if sort is provided filter out the group by columns sort and apply // since we are grouping by the column and applying sort on any other column is not required