Skip to content

Commit

Permalink
fix: throw if where receives an invalid value (#15699)
Browse files Browse the repository at this point in the history
  • Loading branch information
ephys committed Feb 21, 2023
1 parent 48d6193 commit d9e0728
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/dialects/abstract/query-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -2833,7 +2833,7 @@ class QueryGenerator {
});
}

return '1=1';
throw new Error(`Unsupported where option value: ${util.inspect(smth)}. Please refer to the Sequelize documentation to learn more about which values are accepted as part of the where option.`);
}

// A recursive parser for nested where conditions
Expand Down
14 changes: 14 additions & 0 deletions test/unit/sql/get-where-conditions.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const { expect } = require('chai');
const { sequelize } = require('../../support');

describe('QueryGenerator#getWhereConditions', () => {
const queryGenerator = sequelize.queryInterface.queryGenerator;

it('throws if called with invalid arguments', () => {
const User = sequelize.define('User');

expect(() => {
queryGenerator.getWhereConditions(new Date(), User.getTableName(), User);
}).to.throw('Unsupported where option value');
});
});

0 comments on commit d9e0728

Please sign in to comment.