From 87f0a2cd6752f60074b5bf25a368f9c5c61ca9a9 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Mon, 15 Feb 2021 19:01:15 +0000 Subject: [PATCH] Fixing issue with linked rows not handling uniqueness correctly when links between tables are using fieldnames for uniqueness. --- packages/server/src/db/linkedRows/index.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/server/src/db/linkedRows/index.js b/packages/server/src/db/linkedRows/index.js index fb536c5c44..5ea758a976 100644 --- a/packages/server/src/db/linkedRows/index.js +++ b/packages/server/src/db/linkedRows/index.js @@ -118,8 +118,12 @@ exports.attachLinkInfo = async (appId, rows) => { // have to get unique as the previous table query can // return duplicates, could be querying for both tables in a relation const linkVals = getUniqueByProp( - responses.filter(el => el.thisId === row._id), - "id" + responses + // find anything that matches the row's ID we are searching for + .filter(el => el.thisId === row._id) + // create a unique ID which we can use for getting only unique ones + .map(el => ({ ...el, unique: el.id + el.fieldName })), + "unique" ) for (let linkVal of linkVals) { // work out which link pertains to this row