vfk editor - auto select PK

This commit is contained in:
Jan Prochazka 2022-03-10 08:48:52 +01:00
parent 7953186e03
commit 64c8d4bdca

View File

@ -50,6 +50,7 @@
// $: console.log('conid, database', conid, database); // $: console.log('conid, database', conid, database);
// $: console.log('$dbInfo?.tables', $dbInfo?.tables); // $: console.log('$dbInfo?.tables', $dbInfo?.tables);
// $: console.log('tableList', tableList);
</script> </script>
<FormProvider> <FormProvider>
@ -73,6 +74,17 @@
const name = fullNameFromString(e.detail); const name = fullNameFromString(e.detail);
refTableName = name.pureName; refTableName = name.pureName;
refSchemaName = name.schemaName; 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,
},
];
}
}
} }
}} }}
/> />