fixed analyse of mysql procedures/functions

This commit is contained in:
Jan Prochazka 2022-02-10 18:50:08 +01:00
parent 2ec962e2f1
commit 966307fd3c
3 changed files with 10 additions and 2 deletions

View File

@ -97,7 +97,9 @@ export interface ViewInfo extends SqlObjectInfo {
export interface ProcedureInfo extends SqlObjectInfo {} export interface ProcedureInfo extends SqlObjectInfo {}
export interface FunctionInfo extends SqlObjectInfo {} export interface FunctionInfo extends SqlObjectInfo {
// returnDataType?: string;
}
export interface TriggerInfo extends SqlObjectInfo {} export interface TriggerInfo extends SqlObjectInfo {}

View File

@ -132,6 +132,7 @@ class Analyser extends DatabaseAnalyser {
.map(fp.omit(['objectType'])) .map(fp.omit(['objectType']))
.map(x => ({ .map(x => ({
...x, ...x,
createSql: `DELIMITER //\n\nCREATE PROCEDURE \`${x.pureName}\`()\n${x.routineDefinition}\n\nDELIMITER ;\n`,
objectId: x.pureName, objectId: x.pureName,
contentHash: _.isDate(x.modifyDate) ? x.modifyDate.toISOString() : x.modifyDate, contentHash: _.isDate(x.modifyDate) ? x.modifyDate.toISOString() : x.modifyDate,
})), })),
@ -140,6 +141,9 @@ class Analyser extends DatabaseAnalyser {
.map(fp.omit(['objectType'])) .map(fp.omit(['objectType']))
.map(x => ({ .map(x => ({
...x, ...x,
createSql: `CREATE FUNCTION \`${x.pureName}\`()\nRETURNS ${x.returnDataType} ${
x.isDeterministic == 'YES' ? 'DETERMINISTIC' : 'NOT DETERMINISTIC'
}\n${x.routineDefinition}`,
objectId: x.pureName, objectId: x.pureName,
contentHash: _.isDate(x.modifyDate) ? x.modifyDate.toISOString() : x.modifyDate, contentHash: _.isDate(x.modifyDate) ? x.modifyDate.toISOString() : x.modifyDate,
})), })),

View File

@ -3,7 +3,9 @@ select
ROUTINE_NAME as pureName, ROUTINE_NAME as pureName,
ROUTINE_TYPE as objectType, ROUTINE_TYPE as objectType,
COALESCE(LAST_ALTERED, CREATED) as modifyDate, COALESCE(LAST_ALTERED, CREATED) as modifyDate,
ROUTINE_DEFINITION as createSql DATA_TYPE AS returnDataType,
ROUTINE_DEFINITION as routineDefinition,
IS_DETERMINISTIC as isDeterministic
from information_schema.routines from information_schema.routines
where ROUTINE_SCHEMA = '#DATABASE#' and ROUTINE_NAME =OBJECT_ID_CONDITION where ROUTINE_SCHEMA = '#DATABASE#' and ROUTINE_NAME =OBJECT_ID_CONDITION
`; `;