Skip to content

Commit

Permalink
Remove the need for specifying a length for an output parameter of ty…
Browse files Browse the repository at this point in the history
…pe varchar or nvarchar.
  • Loading branch information
pekim committed Apr 1, 2012
1 parent 13f5508 commit 5765a3d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 4 additions & 2 deletions lib/data-type.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,13 @@ TYPE =
name: 'VarChar'
hasCollation: true
dataLengthLength: 2
maximumLength: 8000
writeParameterData: (buffer, parameter) ->
if parameter.length
length = parameter.length
else if parameter.value
length = parameter.value.length
else length = 1 # Can't declare length less than 1 character.
else length = @.maximumLength

# ParamMetaData (TYPE_INFO)
buffer.writeUInt8(@.id)
Expand All @@ -172,12 +173,13 @@ TYPE =
name: 'NVarChar'
hasCollation: true
dataLengthLength: 2
maximumLength: 4000
writeParameterData: (buffer, parameter) ->
if parameter.length
length = 2 * parameter.length
else if parameter.value
length = 2 * parameter.value.length
else length = 2 # Can't declare length less than 1 character.
else length = @maximumLength

# ParamMetaData (TYPE_INFO)
buffer.writeUInt8(@.id)
Expand Down
4 changes: 1 addition & 3 deletions test/integration/rpc-test.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,7 @@ testProcOutput = (test, type, typeAsString, value) ->
)

request.addParameter(type, 'paramIn', value)
request.addOutputParameter(type, 'paramOut',
length: 10
)
request.addOutputParameter(type, 'paramOut')

request.on('doneProc', (rowCount, more, returnStatus) ->
test.ok(!more)
Expand Down

0 comments on commit 5765a3d

Please sign in to comment.