disallow accidental undefined as a find value

This commit is contained in:
AJ ONeal 2016-03-23 03:37:20 +00:00
parent cb39b6282e
commit 422be49b1a
1 changed files with 9 additions and 9 deletions

View File

@ -226,15 +226,15 @@ function wrap(db, dir, dbsMap) {
}); });
}; };
DB.find = function (obj1, params) { DB.find = function (obj, params) {
//var obj = obj1; var err;
var obj = {}; Object.keys(obj).forEach(function (key) {
if (obj1) { if (undefined === obj[key]) {
Object.keys(obj1).forEach(function (key) { err = new Error("'" + key + "' was `undefined'. For security purposes you must explicitly set the value to null or ''");
if (undefined !== obj1[key]) {
obj[key] = obj1[key];
} }
}); });
if (err) {
return PromiseA.reject(err);
} }
var sql = 'SELECT * FROM \'' + tablename + '\' '; var sql = 'SELECT * FROM \'' + tablename + '\' ';
var keys = obj && Object.keys(obj); var keys = obj && Object.keys(obj);