Make sure invalid fields are filtered out

This commit is contained in:
Raymond Feng 2015-05-13 15:03:49 -07:00
parent da64cea7c4
commit 2cb0f5280a
1 changed files with 4 additions and 2 deletions

View File

@ -914,8 +914,10 @@ SQLConnector.prototype.buildColumnNames = function(model, filter) {
var self = this; var self = this;
var keys = Object.keys(cols); var keys = Object.keys(cols);
if (Array.isArray(fieldsFilter) && fieldsFilter.length > 0) { if (Array.isArray(fieldsFilter) && fieldsFilter.length > 0) {
// No empty array, including all the fields // Not empty array, including all the fields that are valid properties
keys = fieldsFilter; keys = fieldsFilter.filter(function(f) {
return cols[f];
});
} else if ('object' === typeof fieldsFilter && } else if ('object' === typeof fieldsFilter &&
Object.keys(fieldsFilter).length > 0) { Object.keys(fieldsFilter).length > 0) {
// { field1: boolean, field2: boolean ... } // { field1: boolean, field2: boolean ... }