fix: reject filter objects in destroyAll method

This commit is contained in:
biniam 2018-09-06 10:39:53 -04:00
parent dbfebb845b
commit e1cc0d70a9
1 changed files with 14 additions and 1 deletions

View File

@ -780,7 +780,11 @@ SQLConnector.prototype.buildDelete = function(model, where, options) {
* @param {Function} cb The callback function
*/
SQLConnector.prototype.destroyAll = function(model, where, options, cb) {
var stmt = this.buildDelete(model, where, options);
try {
var stmt = this.buildDelete(model, where, options);
} catch (err) {
return cb(err);
}
this._executeAlteringQuery(model, stmt.sql, stmt.params, options, cb || NOOP);
};
@ -1092,6 +1096,15 @@ SQLConnector.prototype._buildWhere = function(model, where) {
}
// The value is not an array, fall back to regular fields
}
if (key === 'where') {
// business as usual if the model has a property named 'where'
if (props[key]) {
continue;
} else {
throw new Error('Filter object detected. Please use a where object instead.');
}
}
var p = props[key];
if (p == null) {
// Unknown property, ignore it