Permalink
Browse files

Added test case for issue #8

  • Loading branch information...
1 parent 8e65d58 commit 17b81918946ee01ffaef1637041bc9eca6d2b452 @cretz committed Mar 20, 2012
Showing with 47 additions and 4 deletions.
  1. +0 −4 lib/row.token.js
  2. +47 −0 test/node-tds.issue0008.test.coffee
View
@@ -38,11 +38,8 @@ exports.RowToken = (function(_super) {
for (index = 0, _len = _ref.length; index < _len; index++) {
column = _ref[index];
val = {};
- context.debug('Checking column: ', column);
if (column.type.hasTextPointer) {
len = stream.readByte();
- context.debug('Got len: ', len);
- context.debug('Offset, length', stream.currentOffset(), stream.getBuffer().length);
if (len !== 0) {
stream.skip(len + 8);
} else {
@@ -105,7 +102,6 @@ exports.RowToken = (function(_super) {
} else if (val.length > 0) {
val.buffer = stream.readBuffer(val.length);
}
- context.debug('Got value: ', val);
_results.push(this.values[index] = val);
}
return _results;
@@ -0,0 +1,47 @@
+{TestConstants} = require './constants.test'
+{TestUtils} = require './utils.test'
+
+describe 'Statement', ->
+
+ describe '#execute', ->
+ conn = null
+ beforeEach ->
+ conn = TestUtils.newConnection()
+
+ afterEach ->
+ conn?.end()
+
+ it 'should handle identities properly', (alldone) ->
+ # 0 create table, 1 insert, 2 select
+ stage = 0
+ foundRow = false
+ handler =
+ error: (error) ->
+ alldone error
+ row: (row) ->
+ if stage is 2
+ TestUtils.assertRow row, 'Id', '1'
+ TestUtils.assertRow row, 'Val', 'test'
+ foundRow = true
+ done: (done) ->
+ if stage is 0
+ stage = 1
+ stmt = conn.createStatement "INSERT INTO ##TempTable VALUES ('test')", null, handler
+ stmt.execute()
+ else if stage is 1
+ stage = 2
+ stmt = conn.createStatement 'SELECT * FROM ##TempTable', null, handler
+ stmt.execute()
+ else if foundRow
+ alldone()
+ else
+ alldone new Error('Did not find row')
+ conn.connect =>
+ sql = """
+ CREATE TABLE ##TempTable (
+ Id BIGINT NOT NULL IDENTITY (1, 1),
+ Val VARCHAR(20) NOT NULL
+ )
+ """
+ stmt = conn.createStatement sql, null, handler
+ stmt.execute()

0 comments on commit 17b8191

Please sign in to comment.