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

Commit 0b1e3c49 by Mick Hansen

fix(sql/where): fix issue with {field: {: []}}, closes #3219

1 parent 5bc2d11c
# Next # Next
- [BUG] Fixed support for 2 x belongsToMany without foreignKey defined and association getter/adder [#3185](https://github.com/sequelize/sequelize/issues/3185) - [BUG] Fixed support for 2 x belongsToMany without foreignKey defined and association getter/adder [#3185](https://github.com/sequelize/sequelize/issues/3185)
- [BUG] No longer throws on `Model.hasHook()` if no hooks are defiend [#3181](https://github.com/sequelize/sequelize/issues/3181) - [BUG] No longer throws on `Model.hasHook()` if no hooks are defiend [#3181](https://github.com/sequelize/sequelize/issues/3181)
- [BUG] Fixed issue with `{$and: []}`
# 2.0.3 # 2.0.3
- [BUG] Support for plain strings, ints and bools on JSON insert - [BUG] Support for plain strings, ints and bools on JSON insert
......
...@@ -1680,7 +1680,7 @@ module.exports = (function() { ...@@ -1680,7 +1680,7 @@ module.exports = (function() {
if (value.$or || value.$and) { if (value.$or || value.$and) {
binding = value.$or ? ' OR ' : ' AND '; binding = value.$or ? ' OR ' : ' AND ';
value = value.$or.map(function (_value) { value = (value.$or || value.$and).map(function (_value) {
return self.whereItemQuery(key, _value, options); return self.whereItemQuery(key, _value, options);
}).filter(function (item) { }).filter(function (item) {
return item && item.length; return item && item.length;
......
...@@ -219,6 +219,30 @@ suite(Support.getTestDialectTeaser('SQL'), function() { ...@@ -219,6 +219,30 @@ suite(Support.getTestDialectTeaser('SQL'), function() {
default: "([shared] = 1 AND ([group_id] = 1 OR [user_id] = 2))" default: "([shared] = 1 AND ([group_id] = 1 OR [user_id] = 2))"
}); });
testsql('$and', [
{
name: {
$like: '%hello'
}
},
{
name: {
$like: 'hello%'
}
}
], {
default: "([name] LIKE '%hello' AND [name] LIKE 'hello%')"
});
testsql('name', {
$and: [
{like : '%someValue1%'},
{like : '%someValue2%'}
]
}, {
default: "([name] LIKE '%someValue1%' AND [name] LIKE '%someValue2%')"
})
test("sequelize.and({shared: 1, sequelize.or({group_id: 1}, {user_id: 2}))", function () { test("sequelize.and({shared: 1, sequelize.or({group_id: 1}, {user_id: 2}))", function () {
expectsql(sql.whereItemQuery(undefined, this.sequelize.and({shared: 1}, this.sequelize.or({group_id: 1}, {user_id: 2}))), { expectsql(sql.whereItemQuery(undefined, this.sequelize.and({shared: 1}, this.sequelize.or({group_id: 1}, {user_id: 2}))), {
default: "([shared] = 1 AND ([group_id] = 1 OR [user_id] = 2))" default: "([shared] = 1 AND ([group_id] = 1 OR [user_id] = 2))"
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!