Browse Source

fix: clear single query cache when display value of linked table is changed

pull/8021/head
Pranav C 8 months ago
parent
commit
2dc59ef415
  1. 17
      packages/nocodb/src/models/Model.ts

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

@ -9,7 +9,7 @@ import dayjs from 'dayjs';
import type { BoolType, TableReqType, TableType } from 'nocodb-sdk';
import type { XKnex } from '~/db/CustomKnex';
import type { LinkToAnotherRecordColumn } from '~/models/index';
import type { LinksColumn, LinkToAnotherRecordColumn } from '~/models/index';
import Hook from '~/models/Hook';
import Audit from '~/models/Audit';
import View from '~/models/View';
@ -817,6 +817,21 @@ export default class Model implements TableType {
}
}
// clear all single query cache of related views
for (const col of model.columns) {
if (!isLinksOrLTAR(col)) continue;
const colOptions = await col.getColOptions<
LinkToAnotherRecordColumn | LinksColumn
>();
if (colOptions.fk_related_model_id === model.id) {
await View.clearSingleQueryCache(
colOptions.fk_related_model_id,
null,
ncMeta,
);
}
}
return true;
}

Loading…
Cancel
Save