Skip to content

Commit

Permalink
added some more test for big int as well as a proper fix
Browse files Browse the repository at this point in the history
Signed-off-by: Zach Aller <zachaller@hotmail.com>
  • Loading branch information
zachaller committed Sep 5, 2012
1 parent da3f853 commit ef1c8b6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
5 changes: 4 additions & 1 deletion src/data-type.coffee
Expand Up @@ -179,7 +179,10 @@ TYPE =
# ParamLenData
if parameter.value
buffer.writeUInt8(8)
buffer.writeInt32LE(parseInt(parameter.value) % 0x100000000)
if parseInt(parameter.value) > 0x100000000 # 4294967296
buffer.writeUInt32LE(parseInt(parameter.value) % 0x100000000)
else
buffer.writeInt32LE(parseInt(parameter.value) % 0x100000000)
buffer.writeInt32LE(Math.floor(parseInt(parameter.value) / 0x100000000))
else
buffer.writeUInt8(0)
Expand Down
20 changes: 16 additions & 4 deletions test/integration/parameterised-statements-test.coffee
Expand Up @@ -47,10 +47,16 @@ exports.int = (test) ->
execSql(test, TYPES.Int, 8)

exports.bigint = (test) ->
execSql(test, TYPES.BigInt, 18014402804449279)
execSql(test, TYPES.BigInt, 9007199254740992)

exports.bigint1 = (test) ->
execSql(test, TYPES.BigInt, 1)

exports.bigintsmall = (test) ->
execSql(test, TYPES.BigInt, -8)
execSql(test, TYPES.BigInt, -9007199254740992)

exports.bigintsmall1 = (test) ->
execSql(test, TYPES.BigInt, -1)

exports.float = (test) ->
execSql(test, TYPES.Float, 9654.2546456567565767644)
Expand Down Expand Up @@ -133,10 +139,16 @@ exports.outputInt = (test) ->
execSqlOutput(test, TYPES.Int, 3)

exports.outputBigInt = (test) ->
execSqlOutput(test, TYPES.BigInt, 5294967296)
execSqlOutput(test, TYPES.BigInt, 9007199254740992)

exports.outputBigInt1 = (test) ->
execSqlOutput(test, TYPES.BigInt, 1)

exports.outputBigIntSmall = (test) ->
execSqlOutput(test, TYPES.BigInt, 8)
execSqlOutput(test, TYPES.BigInt, -9007199254740992)

exports.outputBigIntSmall1 = (test) ->
execSqlOutput(test, TYPES.BigInt, -1)

exports.outputFloat = (test) ->
execSqlOutput(test, TYPES.Float, 9654.2546456567565767644)
Expand Down

0 comments on commit ef1c8b6

Please sign in to comment.