Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

completed updating integration tests to test uniqueidentifierN / guid #56

Closed
wants to merge 6 commits into from

2 participants

@cortfritz

also guid now returns alpha in uppercase.

Cort Fritz and others added some commits
Cort Fritz Update src/guid-parser.coffee
helper to reverse the guid-to-array parsing for use on the way back out
049b39f
Cort Fritz moved guid parsing to buffer reading d687e25
Cort Fritz Merge branch 'master' of https://github.com/pekim/tedious
..to ensure I have latest.
4e815b8
Cort Fritz converted test to check for string guid on way out d90ccd7
Cort Fritz fixed integration tests c23a740
@pekim
Owner

Looking good.

You might want to remove some files.

test-connection.json
tests-connection.json
@cortfritz
@cortfritz

closing to offer another pull with correction

@cortfritz cortfritz closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 1, 2012
  1. Update src/guid-parser.coffee

    Cort Fritz authored
    helper to reverse the guid-to-array parsing for use on the way back out
Commits on Oct 26, 2012
  1. moved guid parsing to buffer reading

    Cort Fritz authored
Commits on Oct 29, 2012
  1. Merge branch 'master' of https://github.com/pekim/tedious

    Cort Fritz authored
    ..to ensure I have latest.
  2. converted test to check for string guid on way out

    Cort Fritz authored
Commits on Oct 30, 2012
  1. fixed integration tests

    Cort Fritz authored
Commits on Oct 31, 2012
This page is out of date. Refresh to see the latest.
View
33 src/guid-parser.coffee
@@ -21,4 +21,35 @@ guidToArray = (guid) ->
final = [b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15, b16]
final
-exports.guidToArray = guidToArray
+exports.guidToArray = guidToArray
+
+formatHex = (number) ->
+ hex = number.toString(16)
+ if hex.length == 1
+ hex = '0' + hex
+ return hex
+
+arrayToGuid = (array) ->
+ guid = formatHex(array[3]) +
+ formatHex(array[2]) +
+ formatHex(array[1]) +
+ formatHex(array[0]) +
+ '-' +
+ formatHex(array[5]) +
+ formatHex(array[4]) +
+ '-' +
+ formatHex(array[7]) +
+ formatHex(array[6]) +
+ '-' +
+ formatHex(array[8]) +
+ formatHex(array[9]) +
+ '-' +
+ formatHex(array[10]) +
+ formatHex(array[11]) +
+ formatHex(array[12]) +
+ formatHex(array[13]) +
+ formatHex(array[14]) +
+ formatHex(array[15])
+ guid.toUpperCase()
+
+exports.arrayToGuid = arrayToGuid
View
3  src/value-parser.coffee
@@ -1,5 +1,6 @@
iconv = require('iconv-lite')
sprintf = require('sprintf').sprintf
+guidParser = require('./guid-parser')
require('./buffertools')
NULL = (1 << 16) - 1
@@ -176,7 +177,7 @@ parse = (buffer, metaData) ->
when 0
value = null
when 0x10
- value = buffer.readArray(0x10)
+ value = guidParser.arrayToGuid( buffer.readArray(0x10) )
else
throw new Error(sprintf('Unsupported guid size %d at offset 0x%04X', dataLength - 1, buffer.position))
else
View
6 test/integration/datatypes-in-results-test.coffee
@@ -212,10 +212,8 @@ exports.imageNull = (test) ->
execSql(test, "select cast(null as image)", null)
exports.guid = (test) ->
- execSql(test, "select cast('01234567-89AB-CDEF-0123-456789ABCDEF' as uniqueidentifier)", [
- 0x67, 0x45, 0x23, 0x01, 0xAB, 0x89, 0xEF, 0xCD,
- 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF
- ])
+ execSql(test, "select cast('01234567-89AB-CDEF-0123-456789ABCDEF' as uniqueidentifier)", '01234567-89AB-CDEF-0123-456789ABCDEF')
+
exports.guidNull = (test) ->
execSql(test, "select cast(null as uniqueidentifier)", null)
View
5 test/integration/parameterised-statements-test.coffee
@@ -249,7 +249,7 @@ execSql = (test, type, value) ->
else if (type == TYPES.BigInt)
test.strictEqual(columns[0].value, value.toString())
else if (type == TYPES.UniqueIdentifierN)
- test.deepEqual(columns[0].value, guidParser.guidToArray(value))
+ test.deepEqual(columns[0].value, value)
else
test.strictEqual(columns[0].value, value)
)
@@ -299,7 +299,8 @@ execSqlOutput = (test, type, value) ->
else if (type == TYPES.BigInt)
test.strictEqual(returnValue, value.toString())
else if (type == TYPES.UniqueIdentifierN)
- test.deepEqual(returnValue, guidParser.guidToArray(value))
+
+ test.deepEqual(returnValue, value)
else
test.strictEqual(returnValue, value)
View
6 test/unit/token/row-token-parser-test.coffee
@@ -441,14 +441,14 @@ module.exports.guidN = (test) ->
0,
16, 0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef,0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef
]))
- #console.log(buffer.data)
+ # console.log(buffer.data)
token = parser(new ReadableTrackingBuffer(buffer.data, 'ucs2'), colMetaData)
- #console.log(token)
+ # console.log(token)
test.strictEqual(token.columns.length, 2)
test.strictEqual(token.columns[0].value, null)
- test.deepEqual([0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef,0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef], token.columns[1].value)
+ test.deepEqual('67452301-AB89-EFCD-0123-456789ABCDEF', token.columns[1].value)
test.done()
Something went wrong with that request. Please try again.