Skip to content

Commit

Permalink
fix(MySQL): can't access tables having UNIQUE KEY, closes #69
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabio286 committed May 23, 2021
1 parent f839d5c commit f1636f1
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions src/main/libs/clients/MySQLClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

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('(');

return {
name: nameAndType[0].replaceAll('`', ''),
type: typeAndLength[0].toUpperCase(),
length: typeAndLength[1] ? typeAndLength[1] : null,
default: defaultValue
};
try {
const fieldArr = f.trim().split(' ');
const nameAndType = fieldArr.slice(0, 2);
if (nameAndType[0].charAt(0) !== '`') 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('(');

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) => {
Expand Down

0 comments on commit f1636f1

Please sign in to comment.