Skip to content

Commit

Permalink
Add support for using Real in parameterized statements.
Browse files Browse the repository at this point in the history
  • Loading branch information
pekim committed Apr 1, 2013
1 parent a213adb commit a0a647e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 30 deletions.
28 changes: 11 additions & 17 deletions src/data-type.coffee
Expand Up @@ -98,25 +98,19 @@ TYPE =
0x3B:
type: 'FLT4'
name: 'Real'
# Had some weired rounding issues not sure what was going on
###
declaration: (parameter) ->
'real'
writeParameterData: (buffer, parameter) ->
# ParamMetaData (TYPE_INFO)
# Some issues with rounding
declaration: (parameter) ->
'real'
writeParameterData: (buffer, parameter) ->
# ParamMetaData (TYPE_INFO)
buffer.writeUInt8(typeByName.FloatN.id)
buffer.writeUInt8(4)

buffer.writeUInt8(typeByName.FloatN.id)
# ParamLenData
if parameter.value?
buffer.writeUInt8(4)
# ParamLenData
if parameter.value?
buffer.writeUInt8(4)
buffer.writeFloatLE(parseFloat(parameter.value))
else
buffer.writeUInt8(0)
###
buffer.writeFloatLE(parseFloat(parameter.value))
else
buffer.writeUInt8(0)
0x3C:
type: 'MONEY'
name: 'Money'
Expand Down
29 changes: 16 additions & 13 deletions test/integration/parameterised-statements-test.coffee
Expand Up @@ -45,22 +45,25 @@ exports.smallIntNull = (test) ->

exports.int = (test) ->
execSql(test, TYPES.Int, 8)

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

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

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

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


exports.real = (test) ->
execSql(test, TYPES.Real, 9654.2529296875)

exports.float = (test) ->
execSql(test, TYPES.Float, 9654.2546456567565767644)

exports.uniqueIdentifierN = (test) ->
execSql(test, TYPES.UniqueIdentifierN, '01234567-89AB-CDEF-0123-456789ABCDEF')

Expand Down Expand Up @@ -104,10 +107,10 @@ exports.nVarCharMax = (test) ->

exports.textNull = (test) ->
execSql(test, TYPES.Text, null)

exports.textEmpty = (test) ->
execSql(test, TYPES.Text, '')

exports.textSmall = (test) ->
execSql(test, TYPES.Text, 'small')

Expand Down Expand Up @@ -151,22 +154,22 @@ exports.outputSmallIntNull = (test) ->

exports.outputInt = (test) ->
execSqlOutput(test, TYPES.Int, 3)

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

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

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

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

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

exports.outputUniqueIdentifierN = (test) ->
execSqlOutput(test, TYPES.UniqueIdentifierN, '01234567-89AB-CDEF-0123-456789ABCDEF')

Expand Down

0 comments on commit a0a647e

Please sign in to comment.