fix: reject filter objects in destroyAll method
This commit is contained in:
parent
dbfebb845b
commit
e1cc0d70a9
15
lib/sql.js
15
lib/sql.js
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue