Skip to content

Commit

Permalink
fix: accept undefined in where (#15703)
Browse files Browse the repository at this point in the history
  • Loading branch information
ephys committed Feb 22, 2023
1 parent d9e0728 commit 13f2e89
Show file tree
Hide file tree
Showing 2 changed files with 13 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 @@ -2826,7 +2826,7 @@ class QueryGenerator {
}
throw new Error('Support for literal replacements in the `where` object has been removed.');
}
if (smth === null) {
if (smth == null) {
return this.whereItemsQuery(smth, {
model: factory,
prefix: prepend && tableName
Expand Down
12 changes: 12 additions & 0 deletions test/unit/sql/get-where-conditions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,16 @@ describe('QueryGenerator#getWhereConditions', () => {
queryGenerator.getWhereConditions(new Date(), User.getTableName(), User);
}).to.throw('Unsupported where option value');
});

it('ignores undefined', () => {
const User = sequelize.define('User');

expect(queryGenerator.getWhereConditions(undefined, User.getTableName(), User)).to.eq('');
});

it('ignores null', () => {
const User = sequelize.define('User');

expect(queryGenerator.getWhereConditions(undefined, User.getTableName(), User)).to.eq('');
});
});

0 comments on commit 13f2e89

Please sign in to comment.