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

Commit 8c6c7740 by Brendon Boshell

: [] should also return no data

1 parent b7180e64
......@@ -2005,13 +2005,19 @@ var QueryGenerator = {
});
// $or: [] should return no data.
if (key === '$or' && value.length === 0) {
// $not of no restriction should also return no data
if ((key === '$or' || key === '$not') && value.length === 0) {
return '0 = 1';
}
return value.length ? outerBinding + '('+value.join(binding)+')' : undefined;
} else {
value = self.whereItemsQuery(value, options, binding);
if ((key === '$or' || key === '$not') && !value) {
return '0 = 1';
}
return value ? outerBinding + '('+value+')' : undefined;
}
}
......
......@@ -253,6 +253,10 @@ suite(Support.getTestDialectTeaser('SQL'), function() {
default: "0 = 1"
});
testsql('$or', {}, {
default: "0 = 1"
});
test("sequelize.or()", function () {
expectsql(sql.whereItemQuery(undefined, this.sequelize.or()), {
default: "0 = 1"
......@@ -323,6 +327,14 @@ suite(Support.getTestDialectTeaser('SQL'), function() {
}, {
default: 'NOT ([shared] = 1 AND ([group_id] = 1 OR [user_id] = 2))'
});
testsql('$not', [], {
default: "0 = 1"
});
testsql('$not', {}, {
default: "0 = 1"
});
});
});
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!