Browse Source

fix: include all fields in webhook payload regardless of view - insert/delete/bulk operations

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/6071/head
Pranav C 1 year ago
parent
commit
5b34ffcabd
  1. 40
      packages/nocodb/src/db/BaseModelSqlv2.ts

40
packages/nocodb/src/db/BaseModelSqlv2.ts

@ -1841,7 +1841,12 @@ class BaseModelSqlv2 {
// handle if autogenerated primary key is used // handle if autogenerated primary key is used
if (ag) { if (ag) {
if (!response) await this.execAndParse(query); 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 ( } else if (
!response || !response ||
(typeof response?.[0] !== 'object' && response?.[0] !== null) (typeof response?.[0] !== 'object' && response?.[0] !== null)
@ -1869,7 +1874,7 @@ class BaseModelSqlv2 {
})) as any })) as any
)[0].id; )[0].id;
} }
response = await this.readByPk(id); response = await this.readByPk(id, false, {}, { ignoreView: true });
} else { } else {
response = data; response = data;
} }
@ -1878,6 +1883,9 @@ class BaseModelSqlv2 {
Array.isArray(response) Array.isArray(response)
? response?.[0]?.[ai.title] ? response?.[0]?.[ai.title]
: response?.[ai.title], : response?.[ai.title],
false,
{},
{ ignoreView: true },
); );
} }
@ -1894,7 +1902,7 @@ class BaseModelSqlv2 {
let trx: Transaction = _trx; let trx: Transaction = _trx;
try { try {
// retrieve data for handling params in hook // 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); await this.beforeDelete(id, trx, cookie);
const execQueries: ((trx: Transaction) => Promise<any>)[] = []; const execQueries: ((trx: Transaction) => Promise<any>)[] = [];
@ -2215,7 +2223,7 @@ class BaseModelSqlv2 {
})) as any })) as any
).rows[0].id; ).rows[0].id;
} }
response = await this.readByPk(id); response = await this.readByPk(id, false, {}, { ignoreView: true });
} else { } else {
response = data; response = data;
} }
@ -2483,7 +2491,9 @@ class BaseModelSqlv2 {
if (!raw) { if (!raw) {
for (const pkValues of updatePkValues) { 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 // pk not specified - bypass
continue; continue;
} }
deleted.push(await this.readByPk(pkValues)); deleted.push(
await this.readByPk(pkValues, false, {}, { ignoreView: true }),
);
res.push(d); res.push(d);
} }
@ -3232,7 +3244,12 @@ class BaseModelSqlv2 {
break; 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.afterInsert(response, this.dbDriver, cookie);
await this.afterAddChild(rowId, childId, cookie); await this.afterAddChild(rowId, childId, cookie);
} }
@ -3281,7 +3298,12 @@ class BaseModelSqlv2 {
const childTn = this.getTnPath(childTable); const childTn = this.getTnPath(childTable);
const parentTn = this.getTnPath(parentTable); const parentTn = this.getTnPath(parentTable);
const prevData = await this.readByPk(rowId); const prevData = await this.readByPk(
rowId,
false,
{},
{ ignoreView: true },
);
switch (colOptions.type) { switch (colOptions.type) {
case RelationTypes.MANY_TO_MANY: case RelationTypes.MANY_TO_MANY:
@ -3334,7 +3356,7 @@ class BaseModelSqlv2 {
break; 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.afterUpdate(prevData, newData, this.dbDriver, cookie);
await this.afterRemoveChild(rowId, childId, cookie); await this.afterRemoveChild(rowId, childId, cookie);
} }

Loading…
Cancel
Save