From 052d14ad38335ee0c50fafa6630d29c543026901 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Sun, 20 Jun 2021 10:53:55 +0100 Subject: [PATCH] Fixing issue with 1:N relationships and multiple fields, issue #1753. --- packages/server/src/db/linkedRows/LinkController.js | 4 ++-- packages/worker/src/api/routes/tests/realEmail.spec.js | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/server/src/db/linkedRows/LinkController.js b/packages/server/src/db/linkedRows/LinkController.js index 53ce8e45ad..cba4386105 100644 --- a/packages/server/src/db/linkedRows/LinkController.js +++ b/packages/server/src/db/linkedRows/LinkController.js @@ -211,14 +211,14 @@ class LinkController { // iterate through the link IDs in the row field, see if any don't exist already for (let linkId of rowField) { if (linkedSchema.relationshipType === RelationshipTypes.ONE_TO_MANY) { - const links = ( + let links = ( await getLinkDocuments({ appId: this._appId, tableId: field.tableId, rowId: linkId, includeDocs: IncludeDocs.EXCLUDE, }) - ).filter(link => link.id !== row._id) + ).filter(link => link.id !== row._id && link.fieldName === linkedSchema.name) // The 1 side of 1:N is already related to something else // You must remove the existing relationship diff --git a/packages/worker/src/api/routes/tests/realEmail.spec.js b/packages/worker/src/api/routes/tests/realEmail.spec.js index 8c23141a53..acc0c7acc9 100644 --- a/packages/worker/src/api/routes/tests/realEmail.spec.js +++ b/packages/worker/src/api/routes/tests/realEmail.spec.js @@ -53,7 +53,6 @@ describe("/api/admin/email", () => { it("should be able to send a welcome email", async () => { await sendRealEmail(EmailTemplatePurpose.WELCOME) - }) it("should be able to send a invitation email", async () => {