Comparing version 1.1.9 to 1.1.10
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -7,2 +7,3 @@ 'use strict'; | ||
var BigNumber = require('bignumber.js'); | ||
@@ -30,2 +31,27 @@ /** | ||
/** | ||
* 将sql类型的bigint值转换成nodejs值, 大于13位的数值将使用bignumber, 否者使用number. | ||
* @param {*} sqlValue 数据库bigint值. | ||
*/ | ||
getValueBigInt(sqlValue) { | ||
if (typeof sqlValue === 'string') { | ||
if (sqlValue.length >= 13) // 对千亿以上的数值使用bignumber. | ||
return new BigNumber(sqlValue); | ||
else | ||
return parseInt(sqlValue); | ||
} else { | ||
return sqlValue; | ||
} | ||
}, | ||
/** | ||
* 将sql类型的bit值转换成nodejs值 | ||
* @param {*} sqlValue 数据库bit值. | ||
*/ | ||
getValueBit(sqlValue) { | ||
if (typeof sqlValue === 'boolean') | ||
return sqlValue; | ||
return (1==sqlValue.readUInt8(0)); | ||
}, | ||
/** | ||
* @desc: use string. | ||
@@ -32,0 +58,0 @@ */ |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -68,8 +68,3 @@ 'use strict'; | ||
cret.insertId = ret.recordset[0].identity; | ||
if (typeof cret.insertId === 'string') { | ||
if (cret.insertId.length >= 13) // 对千亿以上的数值使用bignumber. | ||
cret.insertId = new BigNumber(cret.insertId); | ||
else | ||
cret.insertId = parseInt(cret.insertId); | ||
} | ||
cret.insertId = dataType.getValueBigInt(cret.insertId); | ||
} | ||
@@ -98,7 +93,8 @@ } else { | ||
if (typeof rows[i][kk.map] === 'string' && t === dataType.BigInt) { | ||
if (rows[i][kk.map].length >= 13) | ||
rows[i][kk.map] = new BigNumber(rows[i][kk.map]); | ||
else | ||
rows[i][kk.map] = parseInt(rows[i][kk.map]); | ||
rows[i][kk.map] = dataType.getValueBigInt(rows[i][kk.map]); | ||
} | ||
// // fix boolean col. | ||
// else if (t === dataType.Bit) { | ||
// rows[i][kk.map] = dataType.getValueBit(rows[i][kk.map]); | ||
// } | ||
} | ||
@@ -105,0 +101,0 @@ |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -57,8 +57,3 @@ 'use strict'; | ||
cret.insertId = ret.insertId; | ||
if (typeof cret.insertId === 'string') { | ||
if (cret.insertId.length >= 13) // 对千亿以上的数值使用bignumber. | ||
cret.insertId = new BigNumber(cret.insertId); | ||
else | ||
cret.insertId = parseInt(cret.insertId); | ||
} | ||
cret.insertId = dataType.getValueBigInt(cret.insertId); | ||
} | ||
@@ -91,10 +86,7 @@ if (ret instanceof Array) { | ||
if (typeof rows[i][kk.map] === 'string' && t === dataType.BigInt) { | ||
if (rows[i][kk.map].length >= 13) | ||
rows[i][kk.map] = new BigNumber(rows[i][kk.map]); | ||
else | ||
rows[i][kk.map] = parseInt(rows[i][kk.map]); | ||
rows[i][kk.map] = dataType.getValueBigInt(rows[i][kk.map]); | ||
} | ||
// fix boolean col. | ||
else if (t === dataType.Bit) { | ||
rows[i][kk.map] = (1==rows[i][kk.map].readUInt8(0)); | ||
rows[i][kk.map] = dataType.getValueBit(rows[i][kk.map]); | ||
} | ||
@@ -101,0 +93,0 @@ } |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -52,3 +52,3 @@ { | ||
}, | ||
"version": "1.1.9" | ||
"version": "1.1.10" | ||
} |
@@ -0,0 +0,0 @@ |
@@ -0,0 +0,0 @@ |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
235101
3839