mirror of
https://github.com/Fabio286/antares.git
synced 2025-02-08 15:58:45 +01:00
fix(MySQL): can't access tables having UNIQUE KEY, closes #69
This commit is contained in:
parent
f839d5cd3c
commit
f1636f1528
@ -324,21 +324,25 @@ export class MySQLClient extends AntaresCore {
|
||||
.replaceAll('\n', '')
|
||||
.split(',')
|
||||
.map(f => {
|
||||
const fieldArr = f.trim().split(' ');
|
||||
const nameAndType = fieldArr.slice(0, 2);
|
||||
try {
|
||||
const fieldArr = f.trim().split(' ');
|
||||
const nameAndType = fieldArr.slice(0, 2);
|
||||
if (nameAndType[0].charAt(0) !== '`') return false;
|
||||
|
||||
if (!nameAndType[0].includes('`')) return false;
|
||||
const details = fieldArr.slice(2).join(' ');
|
||||
const defaultValue = details.includes('DEFAULT') ? details.match(/(?<=DEFAULT ).*?$/gs)[0] : null;
|
||||
const typeAndLength = nameAndType[1].replace(')', '').split('(');
|
||||
|
||||
const details = fieldArr.slice(2).join(' ');
|
||||
const defaultValue = details.includes('DEFAULT') ? details.match(/(?<=DEFAULT ).*?$/gs)[0] : null;
|
||||
const typeAndLength = nameAndType[1].replace(')', '').split('(');
|
||||
|
||||
return {
|
||||
name: nameAndType[0].replaceAll('`', ''),
|
||||
type: typeAndLength[0].toUpperCase(),
|
||||
length: typeAndLength[1] ? typeAndLength[1] : null,
|
||||
default: defaultValue
|
||||
};
|
||||
return {
|
||||
name: nameAndType[0].replaceAll('`', ''),
|
||||
type: typeAndLength[0].toUpperCase(),
|
||||
length: typeAndLength[1] ? typeAndLength[1] : null,
|
||||
default: defaultValue
|
||||
};
|
||||
}
|
||||
catch (err) {
|
||||
return false;
|
||||
}
|
||||
})
|
||||
.filter(Boolean)
|
||||
.reduce((acc, curr) => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user