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
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<any>)[] = [];
@ -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);
}

Loading…
Cancel
Save