Browse Source

fix: reset alias cache on table rename

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/5832/head
Pranav C 1 year ago
parent
commit
f4219111a5
  1. 12
      packages/nocodb/src/models/Model.ts

12
packages/nocodb/src/models/Model.ts

@ -570,13 +570,25 @@ export default class Model implements TableType {
// get existing cache
const key = `${CacheScope.MODEL}:${tableId}`;
const o = await NocoCache.get(key, CacheGetType.TYPE_OBJECT);
let oldModel = { ...o };
// update alias
if (o) {
o.title = title;
o.table_name = table_name;
// set cache
await NocoCache.set(key, o);
} else {
oldModel = await this.get(tableId);
}
// delete alias cache
await NocoCache.del(
`${CacheScope.MODEL}:${oldModel.project_id}:${oldModel.base_id}:${oldModel.title}`,
);
await NocoCache.del(
`${CacheScope.MODEL}:${oldModel.project_id}:${oldModel.title}`,
);
// set meta
return await ncMeta.metaUpdate(
null,

Loading…
Cancel
Save