From 310cfaa3c2324b1159a46be566b6af2555dc9732 Mon Sep 17 00:00:00 2001 From: Fabio Di Stasio Date: Wed, 26 May 2021 17:44:33 +0200 Subject: [PATCH] fix(MySQL): wrong schema in view data tab select, closes #71 --- src/main/libs/clients/MySQLClient.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/libs/clients/MySQLClient.js b/src/main/libs/clients/MySQLClient.js index a79d0ac8..f158cc08 100644 --- a/src/main/libs/clients/MySQLClient.js +++ b/src/main/libs/clients/MySQLClient.js @@ -305,11 +305,11 @@ export class MySQLClient extends AntaresCore { .select('*') .schema('information_schema') .from('COLUMNS') - .where({ TABLE_SCHEMA: `= '${schema}'`, TABLE_NAME: `= '${table}'` }) + .where({ TABLE_SCHEMA: `= '${this._schema}'`, TABLE_NAME: `= '${table}'` }) .orderBy({ ORDINAL_POSITION: 'ASC' }) .run(); - const { rows: fields } = await this.raw(`SHOW CREATE TABLE ${schema}.${table}`); + const { rows: fields } = await this.raw(`SHOW CREATE TABLE ${this._schema}.${table}`); const remappedFields = fields.map(row => { let n = 0; @@ -330,7 +330,10 @@ export class MySQLClient extends AntaresCore { if (nameAndType[0].charAt(0) !== '`') return false; const details = fieldArr.slice(2).join(' '); - const defaultValue = details.includes('DEFAULT') ? details.match(/(?<=DEFAULT ).*?$/gs)[0] : null; + let defaultValue = null; + if (details.includes('DEFAULT')) + defaultValue = details.match(/(?<=DEFAULT ).*?$/gs)[0].split(' COMMENT')[0]; + const typeAndLength = nameAndType[1].replace(')', '').split('('); return {