From f4e6874ac6f621c34f326964e60a5af4adedce47 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Mon, 10 Jul 2023 18:21:20 +0530 Subject: [PATCH] fix: reset column list cache after column update Signed-off-by: Pranav C --- packages/nocodb/src/models/Column.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/packages/nocodb/src/models/Column.ts b/packages/nocodb/src/models/Column.ts index 1695d1b4db..bbaebabe2c 100644 --- a/packages/nocodb/src/models/Column.ts +++ b/packages/nocodb/src/models/Column.ts @@ -1075,6 +1075,30 @@ export default class Column implements ColumnType { // set cache await NocoCache.set(key, o); } + + // get model column list from cache + const columnListFromCache = await NocoCache.getList(CacheScope.COLUMN, [ + oldCol.fk_model_id, + ]); + + // update column list in cache if cache exists + if (!columnListFromCache.list?.length) { + const updatedColumnList = columnListFromCache.list.map((column: any) => { + if (column.id === colId) { + return { + ...column, + ...updateObj, + }; + } + return column; + }); + await NocoCache.setList( + CacheScope.COLUMN, + [oldCol.fk_model_id], + updatedColumnList, + ); + } + // set meta await ncMeta.metaUpdate( null,