Skip to content
Browse files

Add support for using Real in parameterized statements.

  • Loading branch information...
1 parent a213adb commit a0a647eaba84d7f969ea101debd87b855ce10dd5 @pekim committed Apr 1, 2013
Showing with 27 additions and 30 deletions.
  1. +11 −17 src/data-type.coffee
  2. +16 −13 test/integration/parameterised-statements-test.coffee
View
28 src/data-type.coffee
@@ -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'
View
29 test/integration/parameterised-statements-test.coffee
@@ -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')
@@ -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')
@@ -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')

0 comments on commit a0a647e

Please sign in to comment.
Something went wrong with that request. Please try again.