fix: reject filter objects in destroyAll method
This commit is contained in:
parent
dbfebb845b
commit
e1cc0d70a9
13
lib/sql.js
13
lib/sql.js
|
@ -780,7 +780,11 @@ SQLConnector.prototype.buildDelete = function(model, where, options) {
|
||||||
* @param {Function} cb The callback function
|
* @param {Function} cb The callback function
|
||||||
*/
|
*/
|
||||||
SQLConnector.prototype.destroyAll = function(model, where, options, cb) {
|
SQLConnector.prototype.destroyAll = function(model, where, options, cb) {
|
||||||
|
try {
|
||||||
var stmt = this.buildDelete(model, where, options);
|
var stmt = this.buildDelete(model, where, options);
|
||||||
|
} catch (err) {
|
||||||
|
return cb(err);
|
||||||
|
}
|
||||||
this._executeAlteringQuery(model, stmt.sql, stmt.params, options, cb || NOOP);
|
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
|
// 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];
|
var p = props[key];
|
||||||
if (p == null) {
|
if (p == null) {
|
||||||
// Unknown property, ignore it
|
// Unknown property, ignore it
|
||||||
|
|
Loading…
Reference in New Issue