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 =