diff --git a/lib/waterline/core/typecast.js b/lib/waterline/core/typecast.js index a90bdebda..55b6bf9ea 100644 --- a/lib/waterline/core/typecast.js +++ b/lib/waterline/core/typecast.js @@ -178,7 +178,7 @@ Cast.prototype.boolean = function boolean(value) { if (_.isString(value)) { if (value === 'true') return true; if (value === 'false') return false; - return false; + return value; } // Nicely cast [0, 1] to true and false @@ -191,9 +191,7 @@ Cast.prototype.boolean = function boolean(value) { if (parsed === 0) return false; if (parsed === 1) return true; - if (value === true || value === false) return value; - - return false; + return value; }; /** diff --git a/test/unit/core/core.cast/cast.boolean.js b/test/unit/core/core.cast/cast.boolean.js index 43a470711..5170909ad 100644 --- a/test/unit/core/core.cast/cast.boolean.js +++ b/test/unit/core/core.cast/cast.boolean.js @@ -42,9 +42,9 @@ describe('Core Type Casting', function() { assert(values.name === false); }); - it('should default to false', function() { + it('should not cast bad values', function() { var values = person._cast.run({ name: 'foo' }); - assert(values.name === false); + assert(values.name === 'foo'); }); it('should cast integer 0 to a boolean', function() {