Skip to content

Commit

Permalink
fix(MySQL): wrong schema in view data tab select, closes #71
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabio286 committed May 26, 2021
1 parent 6f93e1f commit 310cfaa
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/main/libs/clients/MySQLClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand Down

0 comments on commit 310cfaa

Please sign in to comment.