From 5b34ffcabd92d219fca5f35e51bd14fa3b665c66 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Sat, 22 Jul 2023 12:00:13 +0530 Subject: [PATCH] fix: include all fields in webhook payload regardless of view - insert/delete/bulk operations Signed-off-by: Pranav C --- packages/nocodb/src/db/BaseModelSqlv2.ts | 40 ++++++++++++++++++------ 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/packages/nocodb/src/db/BaseModelSqlv2.ts b/packages/nocodb/src/db/BaseModelSqlv2.ts index c31d9acba2..b0adba9476 100644 --- a/packages/nocodb/src/db/BaseModelSqlv2.ts +++ b/packages/nocodb/src/db/BaseModelSqlv2.ts @@ -1841,7 +1841,12 @@ class BaseModelSqlv2 { // handle if autogenerated primary key is used if (ag) { if (!response) await this.execAndParse(query); - response = await this.readByPk(data[ag.title]); + response = await this.readByPk( + data[ag.title], + false, + {}, + { ignoreView: true }, + ); } else if ( !response || (typeof response?.[0] !== 'object' && response?.[0] !== null) @@ -1869,7 +1874,7 @@ class BaseModelSqlv2 { })) as any )[0].id; } - response = await this.readByPk(id); + response = await this.readByPk(id, false, {}, { ignoreView: true }); } else { response = data; } @@ -1878,6 +1883,9 @@ class BaseModelSqlv2 { Array.isArray(response) ? response?.[0]?.[ai.title] : response?.[ai.title], + false, + {}, + { ignoreView: true }, ); } @@ -1894,7 +1902,7 @@ class BaseModelSqlv2 { let trx: Transaction = _trx; try { // retrieve data for handling params in hook - const data = await this.readByPk(id); + const data = await this.readByPk(id, false, {}, { ignoreView: true }); await this.beforeDelete(id, trx, cookie); const execQueries: ((trx: Transaction) => Promise)[] = []; @@ -2215,7 +2223,7 @@ class BaseModelSqlv2 { })) as any ).rows[0].id; } - response = await this.readByPk(id); + response = await this.readByPk(id, false, {}, { ignoreView: true }); } else { response = data; } @@ -2483,7 +2491,9 @@ class BaseModelSqlv2 { if (!raw) { for (const pkValues of updatePkValues) { - newData.push(await this.readByPk(pkValues)); + newData.push( + await this.readByPk(pkValues, false, {}, { ignoreView: true }), + ); } } @@ -2575,7 +2585,9 @@ class BaseModelSqlv2 { // pk not specified - bypass continue; } - deleted.push(await this.readByPk(pkValues)); + deleted.push( + await this.readByPk(pkValues, false, {}, { ignoreView: true }), + ); res.push(d); } @@ -3232,7 +3244,12 @@ class BaseModelSqlv2 { break; } - const response = await this.readByPk(rowId); + const response = await this.readByPk( + rowId, + false, + {}, + { ignoreView: true }, + ); await this.afterInsert(response, this.dbDriver, cookie); await this.afterAddChild(rowId, childId, cookie); } @@ -3281,7 +3298,12 @@ class BaseModelSqlv2 { const childTn = this.getTnPath(childTable); const parentTn = this.getTnPath(parentTable); - const prevData = await this.readByPk(rowId); + const prevData = await this.readByPk( + rowId, + false, + {}, + { ignoreView: true }, + ); switch (colOptions.type) { case RelationTypes.MANY_TO_MANY: @@ -3334,7 +3356,7 @@ class BaseModelSqlv2 { break; } - const newData = await this.readByPk(rowId); + const newData = await this.readByPk(rowId, false, {}, { ignoreView: true }); await this.afterUpdate(prevData, newData, this.dbDriver, cookie); await this.afterRemoveChild(rowId, childId, cookie); }