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

Commit 702b79d1 by Daniel Durante

Fixed up smartWhere object for booleans, replicated lodash.compact but also allowed booleans.

1 parent a7ab49b3
Showing with 15 additions and 2 deletions
...@@ -29,6 +29,19 @@ var Utils = module.exports = { ...@@ -29,6 +29,19 @@ var Utils = module.exports = {
} }
return result return result
},
compactLite: function(array) {
var index = -1,
length = array ? array.length : 0,
result = [];
while (++index < length) {
var value = array[index];
if (typeof value === "boolean" || value) {
result.push(value);
}
}
return result;
} }
}) })
...@@ -197,7 +210,7 @@ var Utils = module.exports = { ...@@ -197,7 +210,7 @@ var Utils = module.exports = {
} }
} }
return [text.join(' AND ')].concat(whereArgs.filter(function(w) { return w !== undefined && w !== null })) return Utils._.compactLite([text.join(' AND ')].concat(whereArgs))
}, },
getWhereLogic: function(logic) { getWhereLogic: function(logic) {
switch (logic) { switch (logic) {
......
...@@ -19,7 +19,7 @@ describe(Support.getTestDialectTeaser("HasOne"), function() { ...@@ -19,7 +19,7 @@ describe(Support.getTestDialectTeaser("HasOne"), function() {
Task.create({ title: 'task', status: 'inactive' }).success(function(task) { Task.create({ title: 'task', status: 'inactive' }).success(function(task) {
user.setTaskXYZ(task).success(function() { user.setTaskXYZ(task).success(function() {
user.getTaskXYZ({where: ['status = ?', 'active']}).success(function(task) { user.getTaskXYZ({where: ['status = ?', 'active']}).success(function(task) {
expect(task).to.equal(null) expect(task).to.be.null
done() done()
}) })
}) })
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!