Browse Source

fix: use column id for updating colOptions

pull/7437/head
Pranav C 11 months ago
parent
commit
1204bfced9
  1. 5
      packages/nocodb/src/db/formulav2/formulaQueryBuilderv2.ts
  2. 8
      packages/nocodb/src/models/FormulaColumn.ts

5
packages/nocodb/src/db/formulav2/formulaQueryBuilderv2.ts

@ -1169,7 +1169,7 @@ export default async function formulaQueryBuilderv2(
const formula = await column.getColOptions<FormulaColumn>();
// clean the previous formula error if the formula works this time
if (formula.error) {
await FormulaColumn.update(formula.id, {
await FormulaColumn.update(column.id, {
error: null,
});
}
@ -1179,9 +1179,8 @@ export default async function formulaQueryBuilderv2(
console.error(e);
if (column) {
const formula = await column.getColOptions<FormulaColumn>();
// add formula error to show in UI
await FormulaColumn.update(formula.id, {
await FormulaColumn.update(column.id, {
error: e.message,
});
// update cache to reflect the error in UI

8
packages/nocodb/src/models/FormulaColumn.ts

@ -62,7 +62,7 @@ export default class FormulaColumn {
id: string;
static async update(
id: string,
columnId: string,
formula: Partial<FormulaColumn> & { parsed_tree?: any },
ncMeta = Noco.ncMeta,
) {
@ -75,7 +75,7 @@ export default class FormulaColumn {
]);
// get existing cache
const key = `${CacheScope.COL_FORMULA}:${id}`;
const key = `${CacheScope.COL_FORMULA}:${columnId}`;
let o = await NocoCache.get(key, CacheGetType.TYPE_OBJECT);
if (o) {
o = { ...o, ...updateObj };
@ -85,7 +85,9 @@ export default class FormulaColumn {
if ('parsed_tree' in updateObj)
updateObj.parsed_tree = stringifyMetaProp(updateObj, 'parsed_tree');
// set meta
await ncMeta.metaUpdate(null, null, MetaTable.COL_FORMULA, updateObj, id);
await ncMeta.metaUpdate(null, null, MetaTable.COL_FORMULA, updateObj, {
fk_column_id: columnId,
});
}
public getParsedTree() {

Loading…
Cancel
Save