mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-27 20:46:00 +00:00
delete cascade fix
This commit is contained in:
@@ -55,7 +55,7 @@ function processDependencies(
|
|||||||
schemaName: fk.schemaName,
|
schemaName: fk.schemaName,
|
||||||
},
|
},
|
||||||
alias: 't0',
|
alias: 't0',
|
||||||
relations: subFkPath.map((fkItem, fkIndex) => ({
|
relations: [...subFkPath].reverse().map((fkItem, fkIndex) => ({
|
||||||
joinType: 'INNER JOIN',
|
joinType: 'INNER JOIN',
|
||||||
alias: `t${fkIndex + 1}`,
|
alias: `t${fkIndex + 1}`,
|
||||||
name: {
|
name: {
|
||||||
@@ -123,7 +123,16 @@ export function getDeleteCascades(changeSet: ChangeSet, dbinfo: DatabaseInfo): C
|
|||||||
const table = dbinfo.tables.find(x => x.pureName == baseCmd.pureName && x.schemaName == baseCmd.schemaName);
|
const table = dbinfo.tables.find(x => x.pureName == baseCmd.pureName && x.schemaName == baseCmd.schemaName);
|
||||||
if (!table.primaryKey) continue;
|
if (!table.primaryKey) continue;
|
||||||
|
|
||||||
processDependencies(changeSet, result, allForeignKeys, [], table, baseCmd, dbinfo, [table.pureName]);
|
const itemResult: ChangeSetDeleteCascade[] = [];
|
||||||
|
processDependencies(changeSet, itemResult, allForeignKeys, [], table, baseCmd, dbinfo, [table.pureName]);
|
||||||
|
for (const item of itemResult) {
|
||||||
|
const existing = result.find(x => x.title == item.title);
|
||||||
|
if (existing) {
|
||||||
|
existing.commands.push(...item.commands);
|
||||||
|
} else {
|
||||||
|
result.push(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// let resItem = result.find(x => x.title == baseCmd.pureName);
|
// let resItem = result.find(x => x.title == baseCmd.pureName);
|
||||||
// if (!resItem) {
|
// if (!resItem) {
|
||||||
|
|||||||
Reference in New Issue
Block a user