1
1
mirror of https://github.com/Fabio286/antares.git synced 2025-06-05 21:59:22 +02:00

fix(MySQL): exception exporting empty procedures/functions

This commit is contained in:
2022-03-12 10:37:40 +01:00
parent f0d368e3e3
commit ee415da127
2 changed files with 15 additions and 11 deletions

View File

@ -329,18 +329,20 @@ ${footer}
const fieldName = `Create ${type === 'PROCEDURE' ? 'Procedure' : 'Function'}`; const fieldName = `Create ${type === 'PROCEDURE' ? 'Procedure' : 'Function'}`;
const sqlMode = routine.sql_mode; const sqlMode = routine.sql_mode;
const createProcedure = routine[fieldName]; const createProcedure = routine[fieldName];
const startOffset = createProcedure.indexOf(type);
const procedureBody = createProcedure.substring(startOffset);
let sqlString = ''; let sqlString = '';
sqlString += `/*!50003 DROP ${type} IF EXISTS ${name}*/;;\n`;
sqlString += '/*!50003 SET @OLD_SQL_MODE=@@SQL_MODE*/;;\n'; if (createProcedure) { // If procedure body not empty
sqlString += `/*!50003 SET SQL_MODE="${sqlMode}"*/;;\n`; const startOffset = createProcedure.indexOf(type);
sqlString += 'DELIMITER ;;\n'; const procedureBody = createProcedure.substring(startOffset);
sqlString += `/*!50003 CREATE*/ /*!50020 DEFINER=${definer}*/ /*!50003 ${procedureBody}*/;;\n`;
sqlString += 'DELIMITER ;\n'; sqlString += `/*!50003 DROP ${type} IF EXISTS ${name}*/;;\n`;
sqlString += '/*!50003 SET SQL_MODE=@OLD_SQL_MODE*/;\n'; sqlString += '/*!50003 SET @OLD_SQL_MODE=@@SQL_MODE*/;;\n';
sqlString += `/*!50003 SET SQL_MODE="${sqlMode}"*/;;\n`;
sqlString += 'DELIMITER ;;\n';
sqlString += `/*!50003 CREATE*/ /*!50020 DEFINER=${definer}*/ /*!50003 ${procedureBody}*/;;\n`;
sqlString += 'DELIMITER ;\n';
sqlString += '/*!50003 SET SQL_MODE=@OLD_SQL_MODE*/;\n';
}
return sqlString; return sqlString;
} }

View File

@ -207,12 +207,14 @@ export default {
}, },
hideExportSchemaModal () { hideExportSchemaModal () {
this.isExportSchemaModal = false; this.isExportSchemaModal = false;
this.closeContext();
}, },
showImportSchemaModal () { showImportSchemaModal () {
this.isImportSchemaModal = true; this.isImportSchemaModal = true;
}, },
hideImportSchemaModal () { hideImportSchemaModal () {
this.isImportSchemaModal = false; this.isImportSchemaModal = false;
this.closeContext();
}, },
async initImport () { async initImport () {
const result = await Application.showOpenDialog({ properties: ['openFile'], filters: [{ name: 'SQL', extensions: ['sql'] }] }); const result = await Application.showOpenDialog({ properties: ['openFile'], filters: [{ name: 'SQL', extensions: ['sql'] }] });