From 1952067bd03cdad755cf4c952bae6bfcd495063e Mon Sep 17 00:00:00 2001 From: Pranav C Date: Sat, 10 Jun 2023 11:21:17 +0530 Subject: [PATCH] feat: implement delete behaviour of the Links column Signed-off-by: Pranav C --- packages/nocodb/src/models/Column.ts | 2 +- packages/nocodb/src/services/columns.service.ts | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/packages/nocodb/src/models/Column.ts b/packages/nocodb/src/models/Column.ts index 4e80d0a839..026a03f1f6 100644 --- a/packages/nocodb/src/models/Column.ts +++ b/packages/nocodb/src/models/Column.ts @@ -655,7 +655,7 @@ export default class Column implements ColumnType { } } - // get rollup column and delete + // get rollup/links column and delete { const cachedList = await NocoCache.getList(CacheScope.COL_ROLLUP, [id]); let { list: rollups } = cachedList; diff --git a/packages/nocodb/src/services/columns.service.ts b/packages/nocodb/src/services/columns.service.ts index 47c9bcfbce..f2d4abebc5 100644 --- a/packages/nocodb/src/services/columns.service.ts +++ b/packages/nocodb/src/services/columns.service.ts @@ -41,7 +41,11 @@ import Noco from '../Noco'; import NcConnectionMgrv2 from '../utils/common/NcConnectionMgrv2'; import { MetaTable } from '../utils/globals'; import { MetaService } from '../meta/meta.service'; -import type { LinkToAnotherRecordColumn, Project } from '../models'; +import type { + LinkToAnotherRecordColumn, + Project, + RollupColumn, +} from '../models'; import type SqlMgrv2 from '../db/sql-mgr/v2/SqlMgrv2'; import type { ColumnReqType, @@ -1181,6 +1185,15 @@ export class ColumnsService { case UITypes.Formula: await Column.delete(param.columnId, ncMeta); break; + // When deleting a link column, we need to delete the relation column + // while deleting the LTAR column, links column will be deleted automatically + case UITypes.Links: + return await column.getColOptions().then((colOpt) => + this.columnDelete({ + ...param, + columnId: colOpt.fk_relation_column_id, + }), + ); case UITypes.LinkToAnotherRecord: { const relationColOpt =