Skip to content

Commit

Permalink
Add support for using bit type in parameterised statements.
Browse files Browse the repository at this point in the history
  • Loading branch information
pekim committed May 7, 2012
1 parent 2a73325 commit 2fb0d1a
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/data-type.coffee
Expand Up @@ -26,6 +26,19 @@ TYPE =
0x32:
type: 'BIT'
name: 'Bit'
declaration: () ->
'bit'
writeParameterData: (buffer, parameter) ->
# ParamMetaData (TYPE_INFO)
buffer.writeUInt8(typeByName.BitN.id)
buffer.writeUInt8(1)

# ParamLenData
if typeof parameter.value == 'undefined' || parameter.value == null
buffer.writeUInt8(0)
else
buffer.writeUInt8(1)
buffer.writeUInt8(if parameter.value then 1 else 0)
0x34:
type: 'INT2'
name: 'SmallInt'
Expand Down
22 changes: 22 additions & 0 deletions test/integration/parameterised-statements-test.coffee
Expand Up @@ -15,6 +15,15 @@ getConfig = ->

config

exports.bitTrue = (test) ->
execSql(test, TYPES.Bit, true)

exports.bitFalse = (test) ->
execSql(test, TYPES.Bit, false)

exports.bitNull = (test) ->
execSql(test, TYPES.Bit, null)

exports.tinyInt = (test) ->
execSql(test, TYPES.TinyInt, 8)

Expand Down Expand Up @@ -54,6 +63,15 @@ exports.nVarChar = (test) ->
exports.nVarCharNull = (test) ->
execSql(test, TYPES.NVarChar, null)

exports.outputBitTrue = (test) ->
execSqlOutput(test, TYPES.Bit, true)

exports.outputBitFalse = (test) ->
execSqlOutput(test, TYPES.Bit, false)

exports.outputBitNull = (test) ->
execSqlOutput(test, TYPES.Bit, null)

exports.outputTinyInt = (test) ->
execSqlOutput(test, TYPES.TinyInt, 3)

Expand Down Expand Up @@ -156,6 +174,10 @@ execSql = (test, type, value) ->
test.done()
)

connection.on('errorMessage', (error) ->
console.log("#{error.number} : #{error.message}")
)

connection.on('debug', (text) ->
#console.log(text)
)
Expand Down

0 comments on commit 2fb0d1a

Please sign in to comment.