diff --git a/README.md b/README.md index 76421d5d..a7cbc0ec 100644 --- a/README.md +++ b/README.md @@ -67,4 +67,5 @@ This is a roadmap with major features will come in near future. ## Translations [Giuseppe Gigliotti](https://github.com/ReverbOD) / [Italian Translation](https://github.com/EStarium/antares/pull/20) -[Mohd-PH](https://github.com/Mohd-PH) / [Arabic Translation](https://github.com/EStarium/antares/pull/29) +[Mohd-PH](https://github.com/Mohd-PH) / [Arabic Translation](https://github.com/EStarium/antares/pull/29) +[hongkfui](https://github.com/hongkfui) / [Spanish Translation](https://github.com/EStarium/antares/pull/32) diff --git a/src/main/libs/AntaresConnector.js b/src/main/libs/AntaresConnector.js index 7be976d5..fc73f718 100644 --- a/src/main/libs/AntaresConnector.js +++ b/src/main/libs/AntaresConnector.js @@ -276,10 +276,12 @@ export class AntaresConnector { /** * @param {string} sql raw SQL query + * @param {boolean} [nest] * @returns {Promise} * @memberof AntaresConnector */ - async raw (sql) { + async raw (sql, nest) { + const nestTables = nest ? '.' : false; const resultsArr = []; const queries = sql.split(';'); @@ -292,7 +294,7 @@ export class AntaresConnector { case 'maria': case 'mysql': { const { rows, report, fields } = await new Promise((resolve, reject) => { - this._connection.query({ sql: query, nestTables: false }, (err, response, fields) => { + this._connection.query({ sql: query, nestTables }, (err, response, fields) => { if (err) reject(err); else { diff --git a/src/main/models/Generic.js b/src/main/models/Generic.js index 55bf32d2..cee163d4 100644 --- a/src/main/models/Generic.js +++ b/src/main/models/Generic.js @@ -9,6 +9,6 @@ export default class { return err; } } - return connection.raw(query); + return connection.raw(query, true); } } diff --git a/src/main/models/InformationSchema.js b/src/main/models/InformationSchema.js index af25b345..0cb8baa0 100644 --- a/src/main/models/InformationSchema.js +++ b/src/main/models/InformationSchema.js @@ -27,6 +27,8 @@ export default class { name: field.COLUMN_NAME, key: field.COLUMN_KEY.toLowerCase(), type: field.DATA_TYPE, + schema: field.TABLE_SCHEMA, + table: field.TABLE_NAME, numPrecision: field.NUMERIC_PRECISION, datePrecision: field.DATETIME_PRECISION, charLength: field.CHARACTER_MAXIMUM_LENGTH, diff --git a/src/renderer/components/WorkspaceQueryTable.vue b/src/renderer/components/WorkspaceQueryTable.vue index 54ba8b37..0e7a5261 100644 --- a/src/renderer/components/WorkspaceQueryTable.vue +++ b/src/renderer/components/WorkspaceQueryTable.vue @@ -68,7 +68,7 @@ class="tr" :class="{'selected': selectedRows.includes(row._id)}" @select-row="selectRow($event, row._id)" - @update-field="updateField($event, row[primaryField.alias || primaryField.name])" + @update-field="updateField($event, getPrimaryValue(row))" @contextmenu="contextMenu" /> @@ -200,6 +200,15 @@ export default { return this.resultsWithRows[index].fields[0].orgTable; return ''; }, + getPrimaryValue (row) { + const primaryFieldName = Object.keys(row).find(prop => [ + this.primaryField.alias, + this.primaryField.name, + `${this.primaryField.table}.${this.primaryField.alias}`, + `${this.primaryField.table}.${this.primaryField.name}` + ].includes(prop)); + return row[primaryFieldName]; + }, setLocalResults () { this.resetSort(); this.localResults = this.resultsWithRows[this.resultsetIndex] && this.resultsWithRows[this.resultsetIndex].rows ? this.resultsWithRows[this.resultsetIndex].rows.map(item => { diff --git a/src/renderer/components/WorkspaceQueryTableRow.vue b/src/renderer/components/WorkspaceQueryTableRow.vue index cd796627..e255b791 100644 --- a/src/renderer/components/WorkspaceQueryTableRow.vue +++ b/src/renderer/components/WorkspaceQueryTableRow.vue @@ -281,7 +281,11 @@ export default { return length; }, getFieldObj (cKey) { - return this.fields.filter(field => field.name === cKey || field.alias === cKey)[0]; + return this.fields.filter(field => + field.name === cKey || + field.alias === cKey || + `${field.table}.${field.name}` === cKey || + `${field.table}.${field.alias}` === cKey)[0]; }, isNull (value) { return value === null ? ' is-null' : '';