Browse Source

feat: implement delete behaviour of the Links column

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/5848/head
Pranav C 1 year ago
parent
commit
1952067bd0
  1. 2
      packages/nocodb/src/models/Column.ts
  2. 15
      packages/nocodb/src/services/columns.service.ts

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

@ -655,7 +655,7 @@ export default class Column<T = any> implements ColumnType {
} }
} }
// get rollup column and delete // get rollup/links column and delete
{ {
const cachedList = await NocoCache.getList(CacheScope.COL_ROLLUP, [id]); const cachedList = await NocoCache.getList(CacheScope.COL_ROLLUP, [id]);
let { list: rollups } = cachedList; let { list: rollups } = cachedList;

15
packages/nocodb/src/services/columns.service.ts

@ -41,7 +41,11 @@ import Noco from '../Noco';
import NcConnectionMgrv2 from '../utils/common/NcConnectionMgrv2'; import NcConnectionMgrv2 from '../utils/common/NcConnectionMgrv2';
import { MetaTable } from '../utils/globals'; import { MetaTable } from '../utils/globals';
import { MetaService } from '../meta/meta.service'; 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 SqlMgrv2 from '../db/sql-mgr/v2/SqlMgrv2';
import type { import type {
ColumnReqType, ColumnReqType,
@ -1181,6 +1185,15 @@ export class ColumnsService {
case UITypes.Formula: case UITypes.Formula:
await Column.delete(param.columnId, ncMeta); await Column.delete(param.columnId, ncMeta);
break; 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<RollupColumn>().then((colOpt) =>
this.columnDelete({
...param,
columnId: colOpt.fk_relation_column_id,
}),
);
case UITypes.LinkToAnotherRecord: case UITypes.LinkToAnotherRecord:
{ {
const relationColOpt = const relationColOpt =

Loading…
Cancel
Save