From cdc42d15bd928c6dedc6ed6f2042b24d8cbe64b9 Mon Sep 17 00:00:00 2001 From: Pranav C <61551451+pranavxc@users.noreply.github.com> Date: Mon, 12 Jul 2021 20:07:43 +0530 Subject: [PATCH] fix(api): Avoid duplicate M2M column re #338 Signed-off-by: Pranav C <61551451+pranavxc@users.noreply.github.com> --- packages/nocodb/src/lib/noco/common/BaseApiBuilder.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/nocodb/src/lib/noco/common/BaseApiBuilder.ts b/packages/nocodb/src/lib/noco/common/BaseApiBuilder.ts index 4ff6ca5b89..d4b70234ed 100644 --- a/packages/nocodb/src/lib/noco/common/BaseApiBuilder.ts +++ b/packages/nocodb/src/lib/noco/common/BaseApiBuilder.ts @@ -1288,8 +1288,12 @@ export default abstract class BaseApiBuilder implements XcDynami meta.v = [ ...meta.v.filter(vc => !(vc.hm && meta.manyToMany.some(mm => vc.hm.tn === mm.vtn))), // todo: ignore duplicate m2m relations - ...meta.manyToMany.map(mm => { - + ...meta.manyToMany.filter(v => !meta.v.some(v1 => v1.mm + && ( + v1.mm.tn === v.tn && v.rtn === v1.mm.rtn + || v1.mm.rtn === v.tn && v.tn === v1.mm.rtn + ) && v.vtn === v1.mm.vtn) + ).map(mm => { if (queryParams?.showFields && !(`${mm._tn} <=> ${mm._rtn}` in queryParams.showFields)) { queryParams.showFields[`${mm._tn} <=> ${mm._rtn}`] = true; }