Browse Source

fix: do relation delete only for non-virtual relation

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/5936/head
Pranav C 1 year ago
parent
commit
7b2a02d580
  1. 2
      packages/nocodb/src/meta/meta.service.ts
  2. 10
      packages/nocodb/src/services/columns.service.ts

2
packages/nocodb/src/meta/meta.service.ts

@ -619,7 +619,7 @@ export class MetaService {
offset?: number;
xcCondition?;
fields?: string[];
orderBy: { [key: string]: 'asc' | 'desc' };
orderBy?: { [key: string]: 'asc' | 'desc' };
},
): Promise<any[]> {
const query = this.knexConnection(target);

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

@ -1216,6 +1216,7 @@ export class ColumnsService {
childColumn: mmParentCol,
base,
ncMeta,
virtual: !!relationColOpt.virtual,
},
true,
);
@ -1230,6 +1231,7 @@ export class ColumnsService {
childColumn: mmChildCol,
base,
ncMeta,
virtual: !!relationColOpt.virtual,
},
true,
);
@ -1387,6 +1389,7 @@ export class ColumnsService {
parentTable,
sqlMgr,
ncMeta = Noco.ncMeta,
virtual,
}: {
relationColOpt: LinkToAnotherRecordColumn;
base: Base;
@ -1396,6 +1399,7 @@ export class ColumnsService {
parentTable: Model;
sqlMgr: SqlMgrv2;
ncMeta?: MetaService;
virtual?: boolean;
},
ignoreFkDelete = false,
) => {
@ -1424,7 +1428,7 @@ export class ColumnsService {
foreignKeyName = relationColOpt.fk_index_name;
}
if (!relationColOpt?.virtual) {
if (!relationColOpt?.virtual && !virtual) {
// todo: handle relation delete exception
try {
await sqlMgr.sqlOpPlus(base, 'relationDelete', {
@ -1435,7 +1439,7 @@ export class ColumnsService {
foreignKeyName,
});
} catch (e) {
console.log(e);
console.log(e.message);
}
}
@ -1481,7 +1485,7 @@ export class ColumnsService {
if (index.cn !== childColumn.column_name) continue;
await sqlMgr.sqlOpPlus(base, 'indexDelete', {
...index,
...index,
tn: cTable.table_name,
columns: [childColumn.column_name],
indexName: index.index_name,

Loading…
Cancel
Save