Modernize code copied from SQL API

This commit is contained in:
Javier Goizueta 2018-05-21 15:43:23 +02:00
parent 32092d212e
commit b233f18a0f

View File

@ -260,19 +260,18 @@ function fieldType(cname) {
// columns are returned as an object { columnName1: { type1: ...}, ..}
// for consistency with SQL API
function formatResultFields(dbConnection, flds) {
flds = flds || [];
var nfields = {};
for (var i=0; i<flds.length; ++i) {
var f = flds[i];
var cname = dbConnection.typeName(f.dataTypeID);
var tname;
function formatResultFields(dbConnection, fields = []) {
let nfields = {};
for (let field of fields) {
const cname = dbConnection.typeName(field.dataTypeID);
console.log("FIELD",field);
let tname;
if ( ! cname ) {
tname = 'unknown(' + f.dataTypeID + ')';
tname = 'unknown(' + field.dataTypeID + ')';
} else {
tname = fieldType(cname);
}
nfields[f.name] = { type: tname };
nfields[field.name] = { type: tname };
}
return nfields;
}