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

Commit bdd9005d by Jan Aagaard Meier

Don't remove 0 in compactLite

1 parent dac4e1c8
Showing with 5 additions and 2 deletions
...@@ -30,6 +30,9 @@ var Utils = module.exports = { ...@@ -30,6 +30,9 @@ var Utils = module.exports = {
return result return result
}, },
/*
* Returns an array with some falsy values removed. The values null, "", undefined and NaN are considered falsey.
*/
compactLite: function(array) { compactLite: function(array) {
var index = -1, var index = -1,
length = array ? array.length : 0, length = array ? array.length : 0,
...@@ -37,7 +40,7 @@ var Utils = module.exports = { ...@@ -37,7 +40,7 @@ var Utils = module.exports = {
while (++index < length) { while (++index < length) {
var value = array[index]; var value = array[index];
if (typeof value === "boolean" || value) { if (typeof value === "boolean" || value === 0 || value) {
result.push(value); result.push(value);
} }
} }
...@@ -214,7 +217,7 @@ var Utils = module.exports = { ...@@ -214,7 +217,7 @@ var Utils = module.exports = {
} }
} }
return [text.join(' AND ')].concat(whereArgs) return Utils._.compactLite([text.join(' AND ')].concat(whereArgs))
}, },
getWhereLogic: function(logic) { getWhereLogic: function(logic) {
switch (logic) { switch (logic) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!