Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: reject filter objects in destroyAll method #132

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions lib/sql.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};

Expand Down Expand Up @@ -1092,11 +1096,12 @@ SQLConnector.prototype._buildWhere = function(model, where) {
}
// The value is not an array, fall back to regular fields
}

var p = props[key];
if (p == null) {
// Unknown property, ignore it
debug('Unknown property %s is skipped for model %s', key, model);
continue;
throw new Error(
`Unknown property ${key} used in a "where" condition for model ${model}`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice if we could list all unknown properties in the error message.

);
}
// eslint-disable one-var
var expression = where[key];
Expand Down