Browse Source

fix(api): Avoid duplicate M2M column

re #338

Signed-off-by: Pranav C <61551451+pranavxc@users.noreply.github.com>
pull/341/head
Pranav C 3 years ago
parent
commit
cdc42d15bd
  1. 8
      packages/nocodb/src/lib/noco/common/BaseApiBuilder.ts

8
packages/nocodb/src/lib/noco/common/BaseApiBuilder.ts

@ -1288,8 +1288,12 @@ export default abstract class BaseApiBuilder<T extends Noco> 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;
}

Loading…
Cancel
Save