From 66c13a2a77c9cc86f3d16adbc15599a4239c5acd Mon Sep 17 00:00:00 2001 From: Mel O'Hagan Date: Fri, 13 Jan 2023 11:47:09 +0000 Subject: [PATCH] Try to match primary key or take first --- .../backend/Datasources/CreateEditRelationship.svelte | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/builder/src/components/backend/Datasources/CreateEditRelationship.svelte b/packages/builder/src/components/backend/Datasources/CreateEditRelationship.svelte index ec39cc6d71..d83f3bf9a7 100644 --- a/packages/builder/src/components/backend/Datasources/CreateEditRelationship.svelte +++ b/packages/builder/src/components/backend/Datasources/CreateEditRelationship.svelte @@ -127,7 +127,10 @@ let fromPrimary $: { if (!fromPrimary && fromTable) { - fromPrimary = fromTable.primary[0] + const relationshipKey = fromRelationship?.fieldName + fromPrimary = + fromTable.primary.filter(val => val === relationshipKey)[0] || + fromTable.primary[0] } } $: isManyToMany =