mirror of https://github.com/Fabio286/antares.git
fix(MySQL): wrong schema in view data tab select, closes #71
This commit is contained in:
parent
6f93e1f9ab
commit
310cfaa3c2
|
@ -305,11 +305,11 @@ export class MySQLClient extends AntaresCore {
|
||||||
.select('*')
|
.select('*')
|
||||||
.schema('information_schema')
|
.schema('information_schema')
|
||||||
.from('COLUMNS')
|
.from('COLUMNS')
|
||||||
.where({ TABLE_SCHEMA: `= '${schema}'`, TABLE_NAME: `= '${table}'` })
|
.where({ TABLE_SCHEMA: `= '${this._schema}'`, TABLE_NAME: `= '${table}'` })
|
||||||
.orderBy({ ORDINAL_POSITION: 'ASC' })
|
.orderBy({ ORDINAL_POSITION: 'ASC' })
|
||||||
.run();
|
.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 => {
|
const remappedFields = fields.map(row => {
|
||||||
let n = 0;
|
let n = 0;
|
||||||
|
@ -330,7 +330,10 @@ export class MySQLClient extends AntaresCore {
|
||||||
if (nameAndType[0].charAt(0) !== '`') return false;
|
if (nameAndType[0].charAt(0) !== '`') return false;
|
||||||
|
|
||||||
const details = fieldArr.slice(2).join(' ');
|
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('(');
|
const typeAndLength = nameAndType[1].replace(')', '').split('(');
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Reference in New Issue