mirror of
https://github.com/Fabio286/antares.git
synced 2025-01-27 07:46:17 +01:00
fix: value overridden when join tables with fields with same name
This commit is contained in:
parent
9b76c8eae0
commit
78965d23e3
@ -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)
|
||||
|
@ -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 {
|
||||
|
@ -9,6 +9,6 @@ export default class {
|
||||
return err;
|
||||
}
|
||||
}
|
||||
return connection.raw(query);
|
||||
return connection.raw(query, true);
|
||||
}
|
||||
}
|
||||
|
@ -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,
|
||||
|
@ -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"
|
||||
/>
|
||||
</template>
|
||||
@ -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 => {
|
||||
|
@ -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' : '';
|
||||
|
Loading…
Reference in New Issue
Block a user