diff --git a/src/renderer/components/WorkspaceQueryTab.vue b/src/renderer/components/WorkspaceQueryTab.vue index 5e1e9440..5edf7ee6 100644 --- a/src/renderer/components/WorkspaceQueryTab.vue +++ b/src/renderer/components/WorkspaceQueryTab.vue @@ -139,7 +139,13 @@ export default { if (result.rows) { // if is a select const paramsArr = this.getResultParams(qI); - selectedFields = result.fields.map(field => field.orgName || field.name); + selectedFields = result.fields.map(field => { + return { + name: field.orgName || field.name, + table: field.orgTable || field.table + }; + }); + this.resultsCount += result.rows.length; for (const paramObj of paramsArr) { @@ -153,8 +159,8 @@ export default { if (status === 'success') { let fields = response.length ? selectedFields.map(selField => { - return response.find(field => field.name === selField); - }) : []; + return response.find(field => field.name === selField.name && field.table === selField.table); + }).filter(el => !!el) : []; if (selectedFields.length) { fields = fields.map(field => { @@ -169,11 +175,15 @@ export default { if (!fields.length) { fields = result.fields.map(field => { - return { ...field, alias: field.name }; + return { + ...field, + alias: field.name, + tableAlias: field.table + }; }); } - fieldsArr[qI] = fieldsArr[qI] ? [...fieldsArr[qI], ...fields] : fields.length >= result.fields.length ? fields : result.fields; + fieldsArr[qI] = fieldsArr[qI] ? [...fieldsArr[qI], ...fields] : fields; } else this.addNotification({ status: 'error', message: response }); diff --git a/src/renderer/components/WorkspaceQueryTable.vue b/src/renderer/components/WorkspaceQueryTable.vue index 56b47f1c..d97f7f73 100644 --- a/src/renderer/components/WorkspaceQueryTable.vue +++ b/src/renderer/components/WorkspaceQueryTable.vue @@ -212,7 +212,7 @@ export default { }, getTable (index) { if (this.resultsWithRows[index] && this.resultsWithRows[index].fields && this.resultsWithRows[index].fields.length) - return this.resultsWithRows[index].fields[0].table; + return this.resultsWithRows[index].fields[0].orgTable; return ''; }, getSchema (index) { @@ -221,11 +221,14 @@ export default { return this.workspaceSchema; }, getPrimaryValue (row) { + console.log(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}` + `${this.primaryField.table}.${this.primaryField.name}`, + `${this.primaryField.tableAlias}.${this.primaryField.alias}`, + `${this.primaryField.tableAlias}.${this.primaryField.name}` ].includes(prop)); return row[primaryFieldName]; }, diff --git a/src/renderer/components/WorkspaceQueryTableRow.vue b/src/renderer/components/WorkspaceQueryTableRow.vue index 4393d0e9..efcfa3ee 100644 --- a/src/renderer/components/WorkspaceQueryTableRow.vue +++ b/src/renderer/components/WorkspaceQueryTableRow.vue @@ -285,21 +285,24 @@ export default { return length; }, getFieldObj (cKey) { - return this.fields.filter(field => - field.name === cKey || - field.alias === cKey || + return this.fields.filter(field => { + let fieldNames = [ + field.name, + field.alias, + `${field.table}.${field.name}`, + `${field.table}.${field.alias}`, + `${field.tableAlias}.${field.name}`, + `${field.tableAlias}.${field.alias}` + ]; - `${field.table}.${field.name}` === cKey || - `${field.table}.${field.alias}` === cKey || + if (field.table) + fieldNames = [...fieldNames, `${field.table.toLowerCase()}.${field.name}`, `${field.table.toLowerCase()}.${field.alias}`]; - `${field.table.toLowerCase()}.${field.name}` === cKey || - `${field.table.toLowerCase()}.${field.alias}` === cKey || + if (field.tableAlias) + fieldNames = [...fieldNames, `${field.tableAlias.toLowerCase()}.${field.name}`, `${field.tableAlias.toLowerCase()}.${field.alias}`]; - `${field.tableAlias}.${field.name}` === cKey || - `${field.tableAlias}.${field.alias}` === cKey || - - `${field.tableAlias.toLowerCase()}.${field.name}` === cKey || - `${field.tableAlias.toLowerCase()}.${field.alias}` === cKey)[0]; + return fieldNames.includes(cKey); + })[0]; }, isNull (value) { return value === null ? ' is-null' : ''; diff --git a/src/renderer/scss/main.scss b/src/renderer/scss/main.scss index 2b9cdae6..61cb6cfb 100644 --- a/src/renderer/scss/main.scss +++ b/src/renderer/scss/main.scss @@ -64,6 +64,38 @@ body { background-size: 2em 2em; } +.workspace-tabs { + align-content: baseline; + + .workspace-query-runner { + .workspace-query-runner-footer { + display: flex; + justify-content: space-between; + padding: 0.3rem 0.6rem 0.4rem; + align-items: center; + + .workspace-query-buttons { + display: flex; + + .btn { + display: flex; + align-self: center; + color: $body-font-color; + margin-right: 0.4rem; + } + } + + .workspace-query-info { + display: flex; + + > div + div { + padding-left: 0.6rem; + } + } + } + } +} + // Scrollbars ::-webkit-scrollbar { width: 10px;