mirror of
https://github.com/Fabio286/antares.git
synced 2024-12-26 08:43:10 +01:00
fix: wrong or duplicate fields in some queries
This commit is contained in:
parent
6611aad840
commit
0df2b836b1
@ -145,6 +145,9 @@ export class MySQLClient extends AntaresCore {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// USERS
|
||||||
|
// TODO: SELECT `user`, `host`, IF(LENGTH(password)>0, password, authentication_string) AS `password` FROM `mysql`.`user`;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name: db.Database,
|
name: db.Database,
|
||||||
tables: remappedTables,
|
tables: remappedTables,
|
||||||
@ -662,7 +665,7 @@ export class MySQLClient extends AntaresCore {
|
|||||||
schema: field.db,
|
schema: field.db,
|
||||||
table: field.table,
|
table: field.table,
|
||||||
orgTable: field.orgTable,
|
orgTable: field.orgTable,
|
||||||
type: 'varchar'
|
type: 'VARCHAR'
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
: [];
|
: [];
|
||||||
@ -692,13 +695,13 @@ export class MySQLClient extends AntaresCore {
|
|||||||
|
|
||||||
let detailedFields = response.length
|
let detailedFields = response.length
|
||||||
? selectedFields.map(selField => {
|
? selectedFields.map(selField => {
|
||||||
return response.find(field => field.name === selField.name && field.table === selField.table);
|
return response.find(field => field.name.toLowerCase() === selField.name.toLowerCase() && field.table === selField.table);
|
||||||
}).filter(el => !!el)
|
}).filter(el => !!el)
|
||||||
: [];
|
: [];
|
||||||
|
|
||||||
if (selectedFields.length) {
|
if (selectedFields.length) {
|
||||||
detailedFields = detailedFields.map(field => {
|
detailedFields = detailedFields.map(field => {
|
||||||
const aliasObj = remappedFields.find(resField => resField.orgName === field.name);
|
const aliasObj = remappedFields.find(resField => resField.orgName === field.name && resField.orgTable === field.table);
|
||||||
return {
|
return {
|
||||||
...field,
|
...field,
|
||||||
alias: aliasObj.name || field.name,
|
alias: aliasObj.name || field.name,
|
||||||
@ -709,12 +712,18 @@ export class MySQLClient extends AntaresCore {
|
|||||||
|
|
||||||
if (!detailedFields.length) {
|
if (!detailedFields.length) {
|
||||||
detailedFields = remappedFields.map(field => {
|
detailedFields = remappedFields.map(field => {
|
||||||
return {
|
const isInFields = fieldsArr.some(f => field.name.toLowerCase() === f.name.toLowerCase() && field.table === f.table);
|
||||||
...field,
|
|
||||||
alias: field.name,
|
if (!isInFields) {
|
||||||
tableAlias: field.table
|
return {
|
||||||
};
|
...field,
|
||||||
});
|
alias: field.name,
|
||||||
|
tableAlias: field.table
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}).filter(Boolean);
|
||||||
}
|
}
|
||||||
|
|
||||||
fieldsArr = fieldsArr ? [...fieldsArr, ...detailedFields] : detailedFields;
|
fieldsArr = fieldsArr ? [...fieldsArr, ...detailedFields] : detailedFields;
|
||||||
|
Loading…
Reference in New Issue
Block a user