Skip to content

Commit f80ffe8

Browse files
authored
Merge pull request #446 from marioestradarosa/bool-type-fix
Fix boolean type (#325)
2 parents c5e72db + f821541 commit f80ffe8

File tree

3 files changed

+6001
-1
lines changed

3 files changed

+6001
-1
lines changed

lib/mysql.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,10 @@ MySQL.prototype.fromColumnValue = function(prop, val) {
435435
}
436436
break;
437437
case 'Boolean':
438-
val = Boolean(val);
438+
// BIT(1) case: <Buffer 01> for true and <Buffer 00> for false
439+
// CHAR(1) case: '1' for true and '0' for false
440+
// TINYINT(1) case: 1 for true and 0 for false
441+
val = Buffer.isBuffer(val) && val.length === 1 ? Boolean(val[0]) : Boolean(parseInt(val));
439442
break;
440443
case 'GeoPoint':
441444
case 'Point':

0 commit comments

Comments
 (0)