Merge pull request #1293 from dbgate/feature/FK-test

Feature/fk test
This commit is contained in:
Jan Prochazka
2025-12-09 16:22:29 +01:00
committed by GitHub
8 changed files with 250 additions and 66 deletions

View File

@@ -46,6 +46,8 @@ const dialect = {
dropReferencesWhenDropTable: false,
requireStandaloneSelectForScopeIdentity: true,
dropColumnDependencies: ['dependencies'],
columnProperties: {
columnComment: true,
isUnsigned: true,

View File

@@ -64,6 +64,21 @@ class Dumper extends SqlDumper {
this.putCmd('^alter ^table %f ^rename ^column %i ^to %i', column, column.columnName, newcol);
}
createForeignKeyFore(fk) {
if (fk.constraintName != null && !this.dialect.anonymousForeignKey) {
this.put('^constraint %i ', fk.constraintName);
}
this.put(
'^foreign ^key (%,i) ^references %f (%,i)',
fk.columns.map(x => x.columnName),
{ schemaName: fk.refSchemaName, pureName: fk.refTableName },
fk.columns.map(x => x.refColumnName)
);
if (fk.deleteAction && fk.deleteAction.toUpperCase() !== 'NO ACTION') {
this.put(' ^on ^delete %k', fk.deleteAction);
}
}
// dropTable(obj, options = {}) {
// this.put('^drop ^table');
// if (options.testIfExists) this.put(' ^if ^exists');

View File

@@ -129,6 +129,7 @@ class Analyser extends DatabaseAnalyser {
updateAction: fkcol.on_update,
deleteAction: fkcol.on_delete,
constraintName: `FK_${tableName}_${fkcol.id}`,
constraintType: 'foreignKey',
};
return fk;
});