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

Commit b7180e64 by Brendon Boshell

empty array in where should return no data

1 parent 5c177d97
......@@ -2004,6 +2004,11 @@ var QueryGenerator = {
return item && item.length;
});
// $or: [] should return no data.
if (key === '$or' && value.length === 0) {
return '0 = 1';
}
return value.length ? outerBinding + '('+value.join(binding)+')' : undefined;
} else {
value = self.whereItemsQuery(value, options, binding);
......
......@@ -248,6 +248,16 @@ suite(Support.getTestDialectTeaser('SQL'), function() {
mssql: "([group_id] = 1 OR ([user_id] = 2 AND [role] = N'admin'))"
});
});
testsql('$or', [], {
default: "0 = 1"
});
test("sequelize.or()", function () {
expectsql(sql.whereItemQuery(undefined, this.sequelize.or()), {
default: "0 = 1"
});
});
});
suite('$and', function () {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!