[dataproxy][s] Rename duplicate fieldIds from dataproxy results.
Allow the dataproxy backend to be used for viewing files where the column names are not unique. This occurs, for example, when more than 1 column has not been given a column title at all. Prior to this commit, when encountering such a file, the dataproxy backend would error-out leaving the user without any feedback as to what went wrong.
This commit is contained in:
@@ -56,6 +56,19 @@ this.recline.Backend.DataProxy = this.recline.Backend.DataProxy || {};
|
|||||||
if (results.error) {
|
if (results.error) {
|
||||||
dfd.reject(results.error);
|
dfd.reject(results.error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Rename duplicate fieldIds as each field name needs to be
|
||||||
|
// unique.
|
||||||
|
var seen = {};
|
||||||
|
_.map(results.fields, function(fieldId, index) {
|
||||||
|
if (fieldId in seen) {
|
||||||
|
seen[fieldId] += 1;
|
||||||
|
results.fields[index] = fieldId + "("+seen[fieldId]+")";
|
||||||
|
} else {
|
||||||
|
seen[fieldId] = 1;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
dataset.fields.reset(_.map(results.fields, function(fieldId) {
|
dataset.fields.reset(_.map(results.fields, function(fieldId) {
|
||||||
return {id: fieldId};
|
return {id: fieldId};
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user