From 165fa45fc2b46b501f0c9c57acb8712772bdc45f Mon Sep 17 00:00:00 2001 From: mertmit Date: Mon, 4 Dec 2023 10:24:15 +0300 Subject: [PATCH] fix: group by has many bt part Signed-off-by: mertmit --- packages/nocodb/src/db/BaseModelSqlv2.ts | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/packages/nocodb/src/db/BaseModelSqlv2.ts b/packages/nocodb/src/db/BaseModelSqlv2.ts index 1e5175ea81..b49c80f4be 100644 --- a/packages/nocodb/src/db/BaseModelSqlv2.ts +++ b/packages/nocodb/src/db/BaseModelSqlv2.ts @@ -4457,10 +4457,24 @@ class BaseModelSqlv2 { (d) => d[col.id] && Object.keys(d[col.id]), ); if (btData) { - for (const k of Object.keys(btData[col.id])) { - const btAlias = idToAliasMap[k]; + if (typeof btData[col.id] === 'object') { + for (const k of Object.keys(btData[col.id])) { + const btAlias = idToAliasMap[k]; + if (!btAlias) { + idToAliasPromiseMap[k] = Column.get({ colId: k }).then( + (col) => { + return col.title; + }, + ); + } + } + } else { + // Has Many BT + const btAlias = idToAliasMap[col.id]; if (!btAlias) { - idToAliasPromiseMap[k] = Column.get({ colId: k }).then((col) => { + idToAliasPromiseMap[col.id] = Column.get({ + colId: col.id, + }).then((col) => { return col.title; }); } @@ -4480,7 +4494,7 @@ class BaseModelSqlv2 { const alias = idToAliasMap[key]; if (alias) { if (btMap[key]) { - if (value) { + if (value && typeof value === 'object') { const tempObj = {}; Object.entries(value).forEach(([k, v]) => { const btAlias = idToAliasMap[k];