不要怂,就是干,撸起袖子干!

Commit d585f610 by Mick Hansen

fix(find/where): dont crash on an empty where: [] array. fixes #2849

1 parent d8b2fddd
...@@ -1504,6 +1504,8 @@ module.exports = (function() { ...@@ -1504,6 +1504,8 @@ module.exports = (function() {
} else if (Buffer.isBuffer(smth)) { } else if (Buffer.isBuffer(smth)) {
result = this.escape(smth); result = this.escape(smth);
} else if (Array.isArray(smth)) { } else if (Array.isArray(smth)) {
if (smth.length === 0) return '1=1';
if (Utils.canTreatArrayAsAnd(smth)) { if (Utils.canTreatArrayAsAnd(smth)) {
var _smth = self.sequelize.and.apply(null, smth); var _smth = self.sequelize.and.apply(null, smth);
result = self.getWhereConditions(_smth, tableName, factory, options, prepend); result = self.getWhereConditions(_smth, tableName, factory, options, prepend);
......
...@@ -549,6 +549,12 @@ describe(Support.getTestDialectTeaser('Model'), function() { ...@@ -549,6 +549,12 @@ describe(Support.getTestDialectTeaser('Model'), function() {
}); });
}); });
it('should not crash on an empty where array', function () {
return this.User.findAll({
where: []
});
});
describe('eager loading', function() { describe('eager loading', function() {
describe('belongsTo', function() { describe('belongsTo', function() {
beforeEach(function(done) { beforeEach(function(done) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!