From 210aedbadff93abc43d5860689cdecec6acf025d Mon Sep 17 00:00:00 2001 From: Pranav C Date: Mon, 6 Nov 2023 13:14:56 +0530 Subject: [PATCH] fix: new data api links correction --- packages/nocodb/src/db/BaseModelSqlv2.ts | 28 ++++++++++++++++-------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/packages/nocodb/src/db/BaseModelSqlv2.ts b/packages/nocodb/src/db/BaseModelSqlv2.ts index 21c2604722..f0fd030ef0 100644 --- a/packages/nocodb/src/db/BaseModelSqlv2.ts +++ b/packages/nocodb/src/db/BaseModelSqlv2.ts @@ -4576,20 +4576,20 @@ class BaseModelSqlv2 { break; } - const response = await this.readByPk( + const updatedRow = await this.readByPk( rowId, false, {}, { ignoreView: true, getHiddenColumn: true }, ); - await this.afterUpdate(row, response, this.dbDriver, cookie); + await this.afterUpdate(row, updatedRow, this.dbDriver, cookie); for (const childId of childIds) { await this.afterAddChild(rowId, childId, cookie); } } async removeLinks({ - cookie: _cookie, + cookie, childIds, colId, rowId, @@ -4605,9 +4605,12 @@ class BaseModelSqlv2 { if (!column || !isLinksOrLTAR(column)) NcError.notFound(`Link column ${colId} not found`); - const row = await this.dbDriver(this.tnPath) - .where(await this._wherePk(rowId)) - .first(); + const row = await this.readByPk( + rowId, + false, + {}, + { ignoreView: true, getHiddenColumn: true }, + ); // validate rowId if (!row) { @@ -4786,9 +4789,16 @@ class BaseModelSqlv2 { break; } - // const newData = await this.readByPk(rowId); - // await this.afterUpdate(prevData, newData, this.dbDriver, cookie); - // await this.afterRemoveChild(rowId, childIds, cookie); + const updatedRow = await this.readByPk( + rowId, + false, + {}, + { ignoreView: true, getHiddenColumn: true }, + ); + await this.afterUpdate(row, updatedRow, this.dbDriver, cookie); + for (const childId of childIds) { + await this.afterRemoveChild(rowId, childId, cookie); + } } async btRead(