Browse Source

fix: clear view column cache properly when deleting column

pull/8178/head
Pranav C 8 months ago
parent
commit
68e83c8c51
  1. 7
      packages/nocodb/src/models/CalendarViewColumn.ts
  2. 76
      packages/nocodb/src/models/Column.ts
  3. 4
      packages/nocodb/src/models/FormViewColumn.ts
  4. 7
      packages/nocodb/src/models/GalleryViewColumn.ts
  5. 2
      packages/nocodb/src/models/GridViewColumn.ts
  6. 4
      packages/nocodb/src/models/KanbanViewColumn.ts
  7. 4
      packages/nocodb/src/models/MapViewColumn.ts

7
packages/nocodb/src/models/CalendarViewColumn.ts

@ -79,18 +79,13 @@ export default class CalendarViewColumn {
insertObj.source_id = viewRef.source_id;
}
const { id, fk_column_id } = await ncMeta.metaInsert2(
const { id } = await ncMeta.metaInsert2(
null,
null,
MetaTable.CALENDAR_VIEW_COLUMNS,
insertObj,
);
await NocoCache.set(
`${CacheScope.CALENDAR_VIEW_COLUMN}:${fk_column_id}`,
id,
);
{
const view = await View.get(column.fk_view_id, ncMeta);
await View.clearSingleQueryCache(view.fk_model_id, [view], ncMeta);

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

@ -824,61 +824,81 @@ export default class Column<T = any> implements ColumnType {
}
// Grid View Columns
const gridViewColumns = await ncMeta.metaList2(
null,
null,
MetaTable.GRID_VIEW_COLUMNS,
{
condition: { fk_column_id: id },
},
);
await ncMeta.metaDelete(null, null, MetaTable.GRID_VIEW_COLUMNS, {
fk_column_id: col.id,
fk_column_id: id,
});
const gridViewColumnId = await NocoCache.get(
`${CacheScope.GRID_VIEW_COLUMN}:${col.id}`,
CacheGetType.TYPE_STRING,
);
if (gridViewColumnId) {
for (const gridViewColumn of gridViewColumns) {
await NocoCache.deepDel(
`${CacheScope.GRID_VIEW_COLUMN}:${gridViewColumnId}`,
`${CacheScope.GRID_VIEW_COLUMN}:${gridViewColumn.id}`,
CacheDelDirection.CHILD_TO_PARENT,
);
}
// Form View Columns
const formViewColumns = await ncMeta.metaList2(
null,
null,
MetaTable.FORM_VIEW_COLUMNS,
{
condition: { fk_column_id: id },
},
);
await ncMeta.metaDelete(null, null, MetaTable.FORM_VIEW_COLUMNS, {
fk_column_id: col.id,
fk_column_id: id,
});
const formViewColumnId = await NocoCache.get(
`${CacheScope.FORM_VIEW_COLUMN}:${col.id}`,
CacheGetType.TYPE_STRING,
);
if (formViewColumnId) {
for (const formViewColumn of formViewColumns) {
await NocoCache.deepDel(
`${CacheScope.FORM_VIEW_COLUMN}:${formViewColumnId}`,
`${CacheScope.FORM_VIEW_COLUMN}:${formViewColumn.id}`,
CacheDelDirection.CHILD_TO_PARENT,
);
}
// Kanban View Columns
const kanbanViewColumns = await ncMeta.metaList2(
null,
null,
MetaTable.KANBAN_VIEW_COLUMNS,
{
condition: { fk_column_id: id },
},
);
await ncMeta.metaDelete(null, null, MetaTable.KANBAN_VIEW_COLUMNS, {
fk_column_id: col.id,
fk_column_id: id,
});
const kanbanViewColumnId = await NocoCache.get(
`${CacheScope.KANBAN_VIEW_COLUMN}:${col.id}`,
CacheGetType.TYPE_STRING,
);
if (kanbanViewColumnId) {
for (const kanbanViewColumn of kanbanViewColumns) {
await NocoCache.deepDel(
`${CacheScope.KANBAN_VIEW_COLUMN}:${kanbanViewColumnId}`,
`${CacheScope.KANBAN_VIEW_COLUMN}:${kanbanViewColumn.id}`,
CacheDelDirection.CHILD_TO_PARENT,
);
}
// Gallery View Column
const galleryViewColumns = await ncMeta.metaList2(
null,
null,
MetaTable.GALLERY_VIEW_COLUMNS,
{
condition: { fk_column_id: id },
},
);
await ncMeta.metaDelete(null, null, MetaTable.GALLERY_VIEW_COLUMNS, {
fk_column_id: col.id,
fk_column_id: id,
});
const galleryViewColumnId = await NocoCache.get(
`${CacheScope.GALLERY_VIEW_COLUMN}:${col.id}`,
CacheGetType.TYPE_STRING,
);
if (galleryViewColumnId) {
for (const galleryViewColumn of galleryViewColumns) {
await NocoCache.deepDel(
`${CacheScope.GALLERY_VIEW_COLUMN}:${galleryViewColumnId}`,
`${CacheScope.GALLERY_VIEW_COLUMN}:${galleryViewColumn.id}`,
CacheDelDirection.CHILD_TO_PARENT,
);
}

4
packages/nocodb/src/models/FormViewColumn.ts

@ -92,15 +92,13 @@ export default class FormViewColumn implements FormColumnType {
insertObj.source_id = viewRef.source_id;
}
const { id, fk_column_id } = await ncMeta.metaInsert2(
const { id } = await ncMeta.metaInsert2(
null,
null,
MetaTable.FORM_VIEW_COLUMNS,
insertObj,
);
await NocoCache.set(`${CacheScope.FORM_VIEW_COLUMN}:${fk_column_id}`, id);
return this.get(id, ncMeta).then(async (viewColumn) => {
await NocoCache.appendToList(
CacheScope.FORM_VIEW_COLUMN,

7
packages/nocodb/src/models/GalleryViewColumn.ts

@ -66,18 +66,13 @@ export default class GalleryViewColumn {
insertObj.source_id = viewRef.source_id;
}
const { id, fk_column_id } = await ncMeta.metaInsert2(
const { id } = await ncMeta.metaInsert2(
null,
null,
MetaTable.GALLERY_VIEW_COLUMNS,
insertObj,
);
await NocoCache.set(
`${CacheScope.GALLERY_VIEW_COLUMN}:${fk_column_id}`,
id,
);
// on new view column, delete any optimised single query cache
{
const view = await View.get(column.fk_view_id, ncMeta);

2
packages/nocodb/src/models/GridViewColumn.ts

@ -107,8 +107,6 @@ export default class GridViewColumn implements GridColumnType {
insertObj,
);
await NocoCache.set(`${CacheScope.GRID_VIEW_COLUMN}:${fk_column_id}`, id);
await View.fixPVColumnForView(column.fk_view_id, ncMeta);
// on new view column, delete any optimised single query cache

4
packages/nocodb/src/models/KanbanViewColumn.ts

@ -63,15 +63,13 @@ export default class KanbanViewColumn implements KanbanColumnType {
insertObj.source_id = viewRef.source_id;
}
const { id, fk_column_id } = await ncMeta.metaInsert2(
const { id } = await ncMeta.metaInsert2(
null,
null,
MetaTable.KANBAN_VIEW_COLUMNS,
insertObj,
);
await NocoCache.set(`${CacheScope.KANBAN_VIEW_COLUMN}:${fk_column_id}`, id);
return this.get(id, ncMeta).then(async (kanbanViewColumn) => {
await NocoCache.appendToList(
CacheScope.KANBAN_VIEW_COLUMN,

4
packages/nocodb/src/models/MapViewColumn.ts

@ -57,15 +57,13 @@ export default class MapViewColumn {
insertObj.source_id = viewRef.source_id;
}
const { id, fk_column_id } = await ncMeta.metaInsert2(
const { id } = await ncMeta.metaInsert2(
null,
null,
MetaTable.MAP_VIEW_COLUMNS,
insertObj,
);
await NocoCache.set(`${CacheScope.MAP_VIEW_COLUMN}:${fk_column_id}`, id);
return this.get(id, ncMeta).then(async (viewCol) => {
await NocoCache.appendToList(
CacheScope.MAP_VIEW_COLUMN,

Loading…
Cancel
Save