Skip to content

Commit

Permalink
fix: wrong result fields type and order with some queries
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabio286 committed Oct 20, 2020
1 parent 580105e commit a8cd177
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/main/libs/clients/MySQLClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ export class MySQLClient extends AntaresCore {
const remappedFields = fields ? fields.map(field => {
return {
name: field.name,
orgName: field.orgName,
schema: field.db,
table: field.orgTable,
type: 'varchar'
Expand Down
3 changes: 2 additions & 1 deletion src/renderer/components/SettingBarContext.vue
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export default {
}),
confirmDeleteConnection () {
this.deleteConnection(this.contextConnection);
this.$emit('close-context');
this.closeContext();
},
showEditModal () {
this.isEditModal = true;
Expand All @@ -85,6 +85,7 @@ export default {
},
hideConfirmModal () {
this.isConfirmModal = false;
this.closeContext();
},
closeContext () {
this.$emit('close-context');
Expand Down
17 changes: 10 additions & 7 deletions src/renderer/components/WorkspaceQueryTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,10 @@ export default {
let qI = 0;// queries index
for (const result of this.results) { // cycle queries
let fI = 0;// fields index
if (result.rows) { // if is a select
const paramsArr = this.getResultParams(qI);
selectedFields = result.fields.map(field => field.name);
selectedFields = result.fields.map(field => field.orgName || field.name);
this.resultsCount += result.rows.length;
for (const paramObj of paramsArr) {
Expand All @@ -154,15 +152,20 @@ export default {
const { status, response } = await Tables.getTableColumns(params);
if (status === 'success') {
let fields = response.filter(field => selectedFields.includes(field.name));
let fields = response.length ? selectedFields.map(selField => {
return response.find(field => field.name === selField);
}) : [];
if (selectedFields.length) {
fields = fields.map(field => {
return { ...field, alias: result.fields[fI++].name };
const alias = result.fields.find(resField => resField.orgName === field.name).name || field.name;
return { ...field, alias };
});
}
if (!fields.length) {
fields = response.map(field => {
return { ...field, alias: result.fields[fI++].name };
fields = result.fields.map(field => {
return { ...field, alias: field.name };
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/components/WorkspaceQueryTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
@contextmenu="contextMenu"
/>
</template>
</basevirtualscroll>
</BaseVirtualScroll>
</div>
</div>
</template>
Expand Down
1 change: 1 addition & 0 deletions src/renderer/components/WorkspaceQueryTableRow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ export default {
}
if (BIT.includes(type)) {
if (typeof val === 'number') val = [val];
const hex = Buffer.from(val).toString('hex');
return hexToBinary(hex);
}
Expand Down

0 comments on commit a8cd177

Please sign in to comment.