From 7d026cf99d5f352695267eae0439935ab714ef5c Mon Sep 17 00:00:00 2001 From: Ramesh Mane <101566080+rameshmane7218@users.noreply.github.com> Date: Fri, 5 Jul 2024 08:35:41 +0000 Subject: [PATCH] fix: small changes --- packages/nocodb/src/db/BaseModelSqlv2.ts | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/packages/nocodb/src/db/BaseModelSqlv2.ts b/packages/nocodb/src/db/BaseModelSqlv2.ts index fdd414b201..7c99a04e5b 100644 --- a/packages/nocodb/src/db/BaseModelSqlv2.ts +++ b/packages/nocodb/src/db/BaseModelSqlv2.ts @@ -6233,7 +6233,9 @@ class BaseModelSqlv2 { `Record [id:${childId}] has been linked with record [id:${rowId}] in ${model.title}`, ), details: DOMPurify.sanitize(`${columnTitle} - : ${pkValue ?? null}`), + : ${ + pkValue ?? null + }`), ip: req?.clientIp, user: req?.user?.email, }); @@ -6455,12 +6457,15 @@ class BaseModelSqlv2 { pkValue = undefined, ): Promise { if (!pkValue) { - pkValue = await this.dbDriver(this.getTnPath(childModel)) - .select( - `${childModel.table_name}.${childModel.displayValue.column_name}`, - ) - .where(_wherePk(childModel.primaryKeys, childId)) - .first(); + pkValue = await this.readByPkFromModel( + childModel, + undefined, + true, + childId, + false, + {}, + { ignoreView: true, getHiddenColumn: true, extractOnlyPrimaries: true }, + ); } await Audit.insert({ @@ -6476,7 +6481,9 @@ class BaseModelSqlv2 { ), details: DOMPurify.sanitize(`${columnTitle} : ${ - Object.values(pkValue)[0] + typeof pkValue === 'object' + ? Object.values(pkValue)[0] + : pkValue ?? null }`), ip: req?.clientIp, user: req?.user?.email,