mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-30 23:13:57 +00:00
increment table alias, when multiple tables used
This commit is contained in:
@@ -163,6 +163,7 @@
|
|||||||
left: fromTable.left + 300,
|
left: fromTable.left + 300,
|
||||||
top: fromTable.top + 50,
|
top: fromTable.top + 50,
|
||||||
designerId: newTableDesignerId,
|
designerId: newTableDesignerId,
|
||||||
|
alias: getNewTableAlias(toTable, current.tables),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
references: [
|
references: [
|
||||||
@@ -196,6 +197,14 @@
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getNewTableAlias = (table, tables) => {
|
||||||
|
const usedAliases = (tables || []).map(x => x.alias || x.pureName);
|
||||||
|
if (!usedAliases.includes(table.pureName)) return null;
|
||||||
|
let index = 2;
|
||||||
|
while (usedAliases.includes(`${table.pureName}${index}`)) index += 1;
|
||||||
|
return `${table.pureName}${index}`;
|
||||||
|
};
|
||||||
|
|
||||||
const handleChangeColumn = (column, changeFunc) => {
|
const handleChangeColumn = (column, changeFunc) => {
|
||||||
callChange(current => {
|
callChange(current => {
|
||||||
const currentColumns = (current || {}).columns || [];
|
const currentColumns = (current || {}).columns || [];
|
||||||
@@ -258,7 +267,13 @@
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
...current,
|
...current,
|
||||||
tables: [...((current || {}).tables || []), json],
|
tables: [
|
||||||
|
...((current || {}).tables || []),
|
||||||
|
{
|
||||||
|
...json,
|
||||||
|
alias: getNewTableAlias(json, current?.tables),
|
||||||
|
},
|
||||||
|
],
|
||||||
references:
|
references:
|
||||||
foreignKeys.length == 1
|
foreignKeys.length == 1
|
||||||
? [
|
? [
|
||||||
|
|||||||
Reference in New Issue
Block a user