diff --git a/packages/web/src/tableeditor/VirtualForeignKeyEditorModal.svelte b/packages/web/src/tableeditor/VirtualForeignKeyEditorModal.svelte index c1647c39..a2052ce4 100644 --- a/packages/web/src/tableeditor/VirtualForeignKeyEditorModal.svelte +++ b/packages/web/src/tableeditor/VirtualForeignKeyEditorModal.svelte @@ -50,6 +50,7 @@ // $: console.log('conid, database', conid, database); // $: console.log('$dbInfo?.tables', $dbInfo?.tables); + // $: console.log('tableList', tableList); @@ -73,6 +74,17 @@ const name = fullNameFromString(e.detail); refTableName = name.pureName; refSchemaName = name.schemaName; + if (columns?.length == 1) { + const table = $dbInfo?.tables?.find(x => x.pureName == refTableName && x.schemaName == refSchemaName); + if (table?.primaryKey?.columns?.length == 1) { + columns = [ + { + ...columns[0], + refColumnName: table.primaryKey.columns[0].columnName, + }, + ]; + } + } } }} />