Browse Source

fix: clear single query cache when updating column which is referred a foreign key

pull/9002/head
Pranav C 4 months ago
parent
commit
fd0bf21de7
  1. 36
      packages/nocodb/src/models/Column.ts

36
packages/nocodb/src/models/Column.ts

@ -1264,6 +1264,42 @@ export default class Column<T = any> implements ColumnType {
logger.error(err); logger.error(err);
}); });
} }
// clear any related table cache if updating a FK column
{
// Get LTAR columns in which current column is referenced as foreign key
const ltarColumns = await ncMeta.metaList2(
context.workspace_id,
context.base_id,
MetaTable.COL_RELATIONS,
{
xcCondition: {
_and: [
{
_or: [
{ fk_child_column_id: { eq: colId } },
{ fk_parent_column_id: { eq: colId } },
{ fk_mm_child_column_id: { eq: colId } },
{ fk_mm_parent_column_id: { eq: colId } },
],
},
{
fk_related_model_id: { neq: oldCol.fk_model_id },
},
],
},
},
);
for (const linkCol of ltarColumns) {
await View.clearSingleQueryCache(
context,
(linkCol.colOptions as LinksColumn).fk_related_model_id,
null,
ncMeta,
);
}
}
} }
static async updateAlias( static async updateAlias(

Loading…
Cancel
Save