mssql 3.1.1 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.travis.yml +1 -0
- package/CHANGELOG.txt +17 -1
- package/README.md +154 -125
- package/appveyor.yml +1 -0
- package/lib/connectionstring.js +15 -6
- package/lib/main.js +90 -1
- package/lib/msnodesql.js +40 -4
- package/lib/msnodesqlv8.js +40 -4
- package/lib/tds.js +11 -0
- package/lib/tedious.js +39 -3
- package/package.json +5 -3
- package/src/connectionstring.coffee +7 -3
- package/src/main.coffee +69 -2
- package/src/msnodesql.coffee +34 -2
- package/src/msnodesqlv8.coffee +34 -2
- package/src/tds.coffee +10 -0
- package/src/tedious.coffee +30 -1
package/src/msnodesqlv8.coffee
CHANGED
|
@@ -322,7 +322,23 @@ module.exports = (Connection, Transaction, Request, ConnectionError, Transaction
|
|
|
322
322
|
req.on 'meta', (metadata) =>
|
|
323
323
|
if row
|
|
324
324
|
if isChunkedRecordset
|
|
325
|
-
|
|
325
|
+
if columns[0].name is JSON_COLUMN_ID and @connection.config.parseJSON is true
|
|
326
|
+
try
|
|
327
|
+
row = JSON.parse chunksBuffer.join('')
|
|
328
|
+
if not @stream then recordsets[recordsets.length - 1][0] = row
|
|
329
|
+
catch ex
|
|
330
|
+
row = null
|
|
331
|
+
ex = RequestError new Error("Failed to parse incoming JSON. #{ex.message}"), 'EJSON'
|
|
332
|
+
|
|
333
|
+
if @stream
|
|
334
|
+
@emit 'error', ex
|
|
335
|
+
|
|
336
|
+
else
|
|
337
|
+
console.error ex
|
|
338
|
+
|
|
339
|
+
else
|
|
340
|
+
row[columns[0].name] = chunksBuffer.join ''
|
|
341
|
+
|
|
326
342
|
chunksBuffer = null
|
|
327
343
|
|
|
328
344
|
if @verbose
|
|
@@ -414,7 +430,23 @@ module.exports = (Connection, Transaction, Request, ConnectionError, Transaction
|
|
|
414
430
|
unless @nested
|
|
415
431
|
if row
|
|
416
432
|
if isChunkedRecordset
|
|
417
|
-
|
|
433
|
+
if columns[0].name is JSON_COLUMN_ID and @connection.config.parseJSON is true
|
|
434
|
+
try
|
|
435
|
+
row = JSON.parse chunksBuffer.join('')
|
|
436
|
+
if not @stream then recordsets[recordsets.length - 1][0] = row
|
|
437
|
+
catch ex
|
|
438
|
+
row = null
|
|
439
|
+
ex = RequestError new Error("Failed to parse incoming JSON. #{ex.message}"), 'EJSON'
|
|
440
|
+
|
|
441
|
+
if @stream
|
|
442
|
+
@emit 'error', ex
|
|
443
|
+
|
|
444
|
+
else
|
|
445
|
+
console.error ex
|
|
446
|
+
|
|
447
|
+
else
|
|
448
|
+
row[columns[0].name] = chunksBuffer.join ''
|
|
449
|
+
|
|
418
450
|
chunksBuffer = null
|
|
419
451
|
|
|
420
452
|
if @verbose
|
package/src/tds.coffee
CHANGED
|
@@ -385,6 +385,16 @@ module.exports = (Connection, Transaction, Request, ConnectionError, Transaction
|
|
|
385
385
|
else
|
|
386
386
|
callback? error, if @multiple or @nested then recordsets else recordsets[0]
|
|
387
387
|
|
|
388
|
+
req.on 'message', (msg) =>
|
|
389
|
+
@emit 'info',
|
|
390
|
+
message: msg.text
|
|
391
|
+
number: msg.number
|
|
392
|
+
state: msg.state
|
|
393
|
+
class: msg.severity
|
|
394
|
+
lineNumber: msg.lineNumber
|
|
395
|
+
serverName: msg.serverName
|
|
396
|
+
procName: msg.procName
|
|
397
|
+
|
|
388
398
|
req.on 'error', (err) =>
|
|
389
399
|
e = RequestError err, 'EREQUEST'
|
|
390
400
|
|
package/src/tedious.coffee
CHANGED
|
@@ -290,8 +290,13 @@ module.exports = (Connection, Transaction, Request, ConnectionError, Transaction
|
|
|
290
290
|
_abort: ->
|
|
291
291
|
if not @_rollbackRequested
|
|
292
292
|
# transaction interrupted because of XACT_ABORT
|
|
293
|
+
|
|
294
|
+
pc = @_pooledConnection
|
|
295
|
+
setImmediate =>
|
|
296
|
+
# defer releasing so connection can switch from SentClientRequest to LoggedIn state
|
|
297
|
+
@connection.pool.release pc
|
|
298
|
+
|
|
293
299
|
@_pooledConnection.removeListener 'rollbackTransaction', @_abort
|
|
294
|
-
@connection.pool.release @_pooledConnection
|
|
295
300
|
@_pooledConnection = null
|
|
296
301
|
@_aborted = true
|
|
297
302
|
|
|
@@ -381,6 +386,16 @@ module.exports = (Connection, Transaction, Request, ConnectionError, Transaction
|
|
|
381
386
|
|
|
382
387
|
# we must collect errors even in stream mode
|
|
383
388
|
errors.push e
|
|
389
|
+
|
|
390
|
+
handleInfo = (msg) =>
|
|
391
|
+
@emit 'info',
|
|
392
|
+
message: msg.message
|
|
393
|
+
number: msg.number
|
|
394
|
+
state: msg.state
|
|
395
|
+
class: msg.class
|
|
396
|
+
lineNumber: msg.lineNumber
|
|
397
|
+
serverName: msg.serverName
|
|
398
|
+
procName: msg.procName
|
|
384
399
|
|
|
385
400
|
@_acquire (err, connection) =>
|
|
386
401
|
unless err
|
|
@@ -396,8 +411,10 @@ module.exports = (Connection, Transaction, Request, ConnectionError, Transaction
|
|
|
396
411
|
connection.cancel()
|
|
397
412
|
|
|
398
413
|
# attach handler to handle multiple error messages
|
|
414
|
+
errorHandlers['infoMessage'] = handleInfo
|
|
399
415
|
errorHandlers['errorMessage'] = handleError.bind(undefined, false, connection)
|
|
400
416
|
errorHandlers['error'] = handleError.bind(undefined, true, connection)
|
|
417
|
+
connection.on 'infoMessage', errorHandlers['infoMessage']
|
|
401
418
|
connection.on 'errorMessage', errorHandlers['errorMessage']
|
|
402
419
|
connection.on 'error', errorHandlers['error']
|
|
403
420
|
|
|
@@ -505,6 +522,16 @@ module.exports = (Connection, Transaction, Request, ConnectionError, Transaction
|
|
|
505
522
|
# we must collect errors even in stream mode
|
|
506
523
|
errors.push e
|
|
507
524
|
|
|
525
|
+
handleInfo = (msg) =>
|
|
526
|
+
@emit 'info',
|
|
527
|
+
message: msg.message
|
|
528
|
+
number: msg.number
|
|
529
|
+
state: msg.state
|
|
530
|
+
class: msg.class
|
|
531
|
+
lineNumber: msg.lineNumber
|
|
532
|
+
serverName: msg.serverName
|
|
533
|
+
procName: msg.procName
|
|
534
|
+
|
|
508
535
|
@_acquire (err, connection) =>
|
|
509
536
|
unless err
|
|
510
537
|
if @verbose then @_log "---------- sql #{if @_isBatch then 'batch' else 'query'} ----------\n #{if @_isBatch then 'batch' else 'query'}: #{command}"
|
|
@@ -519,8 +546,10 @@ module.exports = (Connection, Transaction, Request, ConnectionError, Transaction
|
|
|
519
546
|
connection.cancel()
|
|
520
547
|
|
|
521
548
|
# attach handler to handle multiple error messages
|
|
549
|
+
errorHandlers['infoMessage'] = handleInfo
|
|
522
550
|
errorHandlers['errorMessage'] = handleError.bind(undefined, false, connection)
|
|
523
551
|
errorHandlers['error'] = handleError.bind(undefined, true, connection)
|
|
552
|
+
connection.on 'infoMessage', errorHandlers['infoMessage']
|
|
524
553
|
connection.on 'errorMessage', errorHandlers['errorMessage']
|
|
525
554
|
connection.on 'error', errorHandlers['error']
|
|
526
555
|
|