From caf7160e7d3e1c09f452447f19fbb0fbfe344a3d Mon Sep 17 00:00:00 2001 From: Pranav C Date: Sat, 23 Mar 2024 12:19:29 +0530 Subject: [PATCH 1/2] fix: use column title as alias in bulk insert return statement Signed-off-by: Pranav C --- packages/nocodb/src/db/BaseModelSqlv2.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/nocodb/src/db/BaseModelSqlv2.ts b/packages/nocodb/src/db/BaseModelSqlv2.ts index ed998012e5..68987c6256 100644 --- a/packages/nocodb/src/db/BaseModelSqlv2.ts +++ b/packages/nocodb/src/db/BaseModelSqlv2.ts @@ -3582,11 +3582,11 @@ class BaseModelSqlv2 { ); } } else { - const returningArr: string[] = []; + const returningObj: Record = {}; if (!raw) { for (const col of this.model.primaryKeys) { - returningArr.push(col.column_name); + returningObj[col.title] = col.column_name; } } @@ -3594,7 +3594,7 @@ class BaseModelSqlv2 { !raw && (this.isPg || this.isMssql) ? await trx .batchInsert(this.tnPath, insertDatas, chunkSize) - .returning(this.model.primaryKeys?.length ? returningArr : '*') + .returning(this.model.primaryKeys?.length ? returningObj : '*') : await trx.batchInsert(this.tnPath, insertDatas, chunkSize); } @@ -6622,7 +6622,12 @@ export function extractCondition( if (aliasColObjMap[alias]) { if ( - [UITypes.Date, UITypes.DateTime, UITypes.LastModifiedTime, UITypes.CreatedTime].includes(aliasColObjMap[alias].uidt) + [ + UITypes.Date, + UITypes.DateTime, + UITypes.LastModifiedTime, + UITypes.CreatedTime, + ].includes(aliasColObjMap[alias].uidt) ) { value = value?.split(','); // the first element would be sub_op From 74b351483b49001953da8518c0acfbb59445383a Mon Sep 17 00:00:00 2001 From: Pranav C Date: Sat, 23 Mar 2024 18:10:34 +0530 Subject: [PATCH 2/2] refactor: type correction Signed-off-by: Pranav C --- packages/nocodb/src/db/BaseModelSqlv2.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nocodb/src/db/BaseModelSqlv2.ts b/packages/nocodb/src/db/BaseModelSqlv2.ts index 68987c6256..ef874ea280 100644 --- a/packages/nocodb/src/db/BaseModelSqlv2.ts +++ b/packages/nocodb/src/db/BaseModelSqlv2.ts @@ -3582,7 +3582,7 @@ class BaseModelSqlv2 { ); } } else { - const returningObj: Record = {}; + const returningObj: Record = {}; if (!raw) { for (const col of this.model.primaryKeys) {