fix(MySQL): issue obtaining routine/function parameters

This commit is contained in:
Fabio Di Stasio 2021-02-24 19:45:27 +01:00
parent 76d92cd106
commit 3aa2159a1a
1 changed files with 6 additions and 5 deletions

View File

@ -551,18 +551,18 @@ export class MySQLClient extends AntaresCore {
} }
const parameters = row['Create Procedure'] const parameters = row['Create Procedure']
.match(/(?<=\().*?(?=\))/s)[0] .match(/(\([^()]*(?:(?:\([^()]*\))[^()]*)*\)\s*)/s)[0]
.replaceAll('\r', '') .replaceAll('\r', '')
.replaceAll('\t', '') .replaceAll('\t', '')
.slice(1, -1)
.split(',') .split(',')
.map(el => { .map(el => {
const param = el.split(' '); const param = el.split(' ');
const type = param[2] ? param[2].replace(')', '').split('(') : ['', null]; const type = param[2] ? param[2].replace(')', '').split('(') : ['', null];
return { return {
name: param[1] ? param[1].replaceAll('`', '') : '', name: param[1] ? param[1].replaceAll('`', '') : '',
type: type[0].replaceAll('\n', ''), type: type[0].replaceAll('\n', ''),
length: +type[1], length: +type[1].replace(/\D/g, ''),
context: param[0] ? param[0].replace('\n', '') : '' context: param[0] ? param[0].replace('\n', '') : ''
}; };
}).filter(el => el.name); }).filter(el => el.name);
@ -671,9 +671,10 @@ export class MySQLClient extends AntaresCore {
} }
const parameters = row['Create Function'] const parameters = row['Create Function']
.match(/(?<=\().*?(?=\))/s)[0] .match(/(\([^()]*(?:(?:\([^()]*\))[^()]*)*\)\s*)/s)[0]
.replaceAll('\r', '') .replaceAll('\r', '')
.replaceAll('\t', '') .replaceAll('\t', '')
.slice(1, -1)
.split(',') .split(',')
.map(el => { .map(el => {
const param = el.split(' '); const param = el.split(' ');
@ -682,7 +683,7 @@ export class MySQLClient extends AntaresCore {
return { return {
name: param[0] ? param[0].replaceAll('`', '') : '', name: param[0] ? param[0].replaceAll('`', '') : '',
type: type[0], type: type[0],
length: +type[1] length: +type[1].replace(/\D/g, '')
}; };
}).filter(el => el.name); }).filter(el => el.name);