Browse Source

fix: use column id for updating colOptions

pull/7437/head
Pranav C 10 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>(); const formula = await column.getColOptions<FormulaColumn>();
// clean the previous formula error if the formula works this time // clean the previous formula error if the formula works this time
if (formula.error) { if (formula.error) {
await FormulaColumn.update(formula.id, { await FormulaColumn.update(column.id, {
error: null, error: null,
}); });
} }
@ -1179,9 +1179,8 @@ export default async function formulaQueryBuilderv2(
console.error(e); console.error(e);
if (column) { if (column) {
const formula = await column.getColOptions<FormulaColumn>();
// add formula error to show in UI // add formula error to show in UI
await FormulaColumn.update(formula.id, { await FormulaColumn.update(column.id, {
error: e.message, error: e.message,
}); });
// update cache to reflect the error in UI // 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; id: string;
static async update( static async update(
id: string, columnId: string,
formula: Partial<FormulaColumn> & { parsed_tree?: any }, formula: Partial<FormulaColumn> & { parsed_tree?: any },
ncMeta = Noco.ncMeta, ncMeta = Noco.ncMeta,
) { ) {
@ -75,7 +75,7 @@ export default class FormulaColumn {
]); ]);
// get existing cache // get existing cache
const key = `${CacheScope.COL_FORMULA}:${id}`; const key = `${CacheScope.COL_FORMULA}:${columnId}`;
let o = await NocoCache.get(key, CacheGetType.TYPE_OBJECT); let o = await NocoCache.get(key, CacheGetType.TYPE_OBJECT);
if (o) { if (o) {
o = { ...o, ...updateObj }; o = { ...o, ...updateObj };
@ -85,7 +85,9 @@ export default class FormulaColumn {
if ('parsed_tree' in updateObj) if ('parsed_tree' in updateObj)
updateObj.parsed_tree = stringifyMetaProp(updateObj, 'parsed_tree'); updateObj.parsed_tree = stringifyMetaProp(updateObj, 'parsed_tree');
// set meta // 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() { public getParsedTree() {

Loading…
Cancel
Save