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