From 040d45ad5dacc75a5aacab1bb627c7f4be42df7c Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Thu, 24 Mar 2022 13:59:46 +0000 Subject: [PATCH] Fixing a mis-match of fields when creating many-to-many relationships on tables from within Budibase - #5049. --- packages/server/src/api/controllers/table/external.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/server/src/api/controllers/table/external.js b/packages/server/src/api/controllers/table/external.js index 86d855a28e..1263bb6216 100644 --- a/packages/server/src/api/controllers/table/external.js +++ b/packages/server/src/api/controllers/table/external.js @@ -118,8 +118,8 @@ function generateManyLinkSchema(datasource, column, table, relatedTable) { }, } column.through = junctionTable._id - column.throughFrom = primary - column.throughTo = relatedPrimary + column.throughFrom = relatedPrimary + column.throughTo = primary column.fieldName = relatedPrimary return junctionTable } @@ -146,7 +146,7 @@ function generateRelatedSchema(linkColumn, table, relatedTable, columnName) { // is many to many else { // don't need to copy through, already got it - relatedSchema.fieldName = linkColumn.throughFrom + relatedSchema.fieldName = linkColumn.throughTo relatedSchema.throughTo = linkColumn.throughFrom relatedSchema.throughFrom = linkColumn.throughTo }