Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Recompile and NPM goodies

  • Loading branch information...
commit c7d8c36ee0d2d8834326526a5b8a181bc6bee44d 1 parent a1850de
@cretz authored
Showing with 361 additions and 31 deletions.
  1. +6 −0 .npmignore
  2. +22 −0 LICENSE
  3. +5 −9 README
  4. +0 −7 TODO
  5. +6 −0 lib/altmetadata.token.js
  6. +7 −0 lib/attention.packet.js
  7. +4 −1 lib/buffer-builder.js
  8. +5 −0 lib/buffer-stream.js
  9. +6 −0 lib/colmetadata.token.js
  10. +8 −0 lib/done.token.js
  11. +6 −0 lib/envchange.token.js
  12. +6 −0 lib/error.message.token.js
  13. +6 −0 lib/info.message.token.js
  14. +7 −3 lib/login7.packet.js
  15. +6 −0 lib/loginack.token.js
  16. +4 −0 lib/message.token.js
  17. +3 −1 lib/packet.js
  18. +6 −0 lib/prelogin.packet.js
  19. +6 −0 lib/returnstatus.token.js
  20. +11 −1 lib/row.token.js
  21. +6 −0 lib/rpcrequest.packet.js
  22. +6 −0 lib/sqlbatch.packet.js
  23. +4 −0 lib/tds-client.js
  24. +3 −1 lib/tds-constants.js
  25. +3 −1 lib/tds-utils.js
  26. +35 −0 lib/{node-tds.js → tds.js}
  27. +3 −1 lib/token.js
  28. +6 −0 lib/tokenstream.packet.js
  29. +23 −0 package.json
  30. +8 −4 src/altmetadata.token.coffee
  31. +6 −0 src/attention.packet.coffee
  32. +5 −0 src/buffer-builder.coffee
  33. +6 −0 src/buffer-stream.coffee
  34. +5 −0 src/colmetadata.token.coffee
  35. +7 −0 src/done.token.coffee
  36. +5 −0 src/envchange.token.coffee
  37. +5 −0 src/error.message.token.coffee
  38. +5 −0 src/info.message.token.coffee
  39. +6 −1 src/login7.packet.coffee
  40. +5 −0 src/loginack.token.coffee
  41. +3 −0  src/message.token.coffee
  42. +4 −0 src/packet.coffee
  43. +5 −0 src/prelogin.packet.coffee
  44. +5 −0 src/returnstatus.token.coffee
  45. +7 −1 src/row.token.coffee
  46. +5 −0 src/rpcrequest.packet.coffee
  47. +5 −0 src/sqlbatch.packet.coffee
  48. +3 −0  src/tds-client.coffee
  49. +4 −0 src/tds-constants.coffee
  50. +4 −0 src/tds-utils.coffee
  51. +26 −0 src/{node-tds.coffee → tds.coffee}
  52. +3 −0  src/token.coffee
  53. +5 −0 src/tokenstream.packet.coffee
View
6 .npmignore
@@ -0,0 +1,6 @@
+src/
+test/
+node_modules/
+temp/
+.git*
+Cakefile
View
22 LICENSE
@@ -0,0 +1,22 @@
+Copyright (c) 2012 Chad Retz
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
View
14 README
@@ -1,11 +1,7 @@
-This is my playground to see how difficult writing a async friendly
-node.js driver for SQL Server would be. Please don't use this project
-right now!
+node-tds is a client for Microsoft SQL Server databases.
-Features:
+Install:
+npm install tds
-* Parameterized statements
-* Prepared (server-side) statements
-* Full SQL Server 2005 data type support (including Binary and VarBinary)
-* Query cancellation
-* Transactions
+Website:
+http://cretz.github.com/node-tds
View
7 TODO
@@ -1,7 +0,0 @@
-Things to do:
-
-* NTLM SSO auth with current user using C++ add on inspired by ntlmauth.dll from jTDS
-** would love to use node-ffi here once Windows support is complete
-* SQL bulk load
-* TDS server impl too?
-* Multiple result set test
View
6 lib/altmetadata.token.js
@@ -4,6 +4,12 @@ var AltMetaDataToken, Token,
Token = require('./token').Token;
+/**
+Token for ALTMETADATA (0x88)
+
+@spec 2.2.7.1
+*/
+
AltMetaDataToken = (function(_super) {
__extends(AltMetaDataToken, _super);
View
7 lib/attention.packet.js
@@ -4,6 +4,13 @@ var Packet,
Packet = require('./packet').Packet;
+/**
+Packet for ATTENTION (0x06). This is sent to cancel
+a query.
+
+@spec 2.2.1.6
+*/
+
exports.AttentionPacket = (function(_super) {
__extends(AttentionPacket, _super);
View
5 lib/buffer-builder.js
@@ -1,4 +1,7 @@
-
+/**
+Builder for buffers. Basically allows building a buffer
+but the buffer isn't created until toBuffer is called.
+*/
exports.BufferBuilder = (function() {
BufferBuilder.getUcs2StringLength = function(string) {
View
5 lib/buffer-stream.js
@@ -1,3 +1,8 @@
+/**
+Streaming buffer reader. This allows you to mark the beginning
+of the read, and read individual pieces. If the underlying buffer
+isn't big enough, a StreamIndexOutOfBoundsError is thrown.
+*/
var __hasProp = Object.prototype.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };
View
6 lib/colmetadata.token.js
@@ -6,6 +6,12 @@ Token = require('./token').Token;
TdsConstants = require('./tds-constants').TdsConstants;
+/**
+Token for COLMETADATA (0x81)
+
+@spec 2.2.7.4
+*/
+
exports.ColMetaDataToken = (function(_super) {
__extends(ColMetaDataToken, _super);
View
8 lib/done.token.js
@@ -6,6 +6,14 @@ TdsConstants = require('./tds-constants').TdsConstants;
Token = require('./token').Token;
+/**
+Token for DONE (0xFD), DONEINPROC (0xFD), and DONEPROC (0xFE)
+
+@spec 2.2.7.5
+@spec 2.2.7.6
+@spec 2.2.7.7
+*/
+
exports.DoneToken = (function(_super) {
__extends(DoneToken, _super);
View
6 lib/envchange.token.js
@@ -6,6 +6,12 @@ TdsConstants = require('./tds-constants').TdsConstants;
Token = require('./token').Token;
+/**
+Token for ENVCHANGE (0xE3)
+
+@spec 2.2.7.8
+*/
+
exports.EnvChangeToken = (function(_super) {
__extends(EnvChangeToken, _super);
View
6 lib/error.message.token.js
@@ -4,6 +4,12 @@ var MessageToken,
MessageToken = require('./message.token').MessageToken;
+/**
+Token for ERROR (0xAA)
+
+@spec 2.2.7.9
+*/
+
exports.ErrorMessageToken = (function(_super) {
__extends(ErrorMessageToken, _super);
View
6 lib/info.message.token.js
@@ -4,6 +4,12 @@ var MessageToken,
MessageToken = require('./message.token').MessageToken;
+/**
+Token for INFO (0xAB)
+
+@spec 2.2.7.10
+*/
+
exports.InfoMessageToken = (function(_super) {
__extends(InfoMessageToken, _super);
View
10 lib/login7.packet.js
@@ -6,6 +6,12 @@ Packet = require('./packet').Packet;
TdsConstants = require('./tds-constants').TdsConstants;
+/**
+Packet for LOGIN7 (0x10). This is the packet sent for initial login
+
+@spec 2.2.6.3
+*/
+
exports.Login7Packet = (function(_super) {
__extends(Login7Packet, _super);
@@ -72,9 +78,6 @@ exports.Login7Packet = (function(_super) {
Login7Packet.prototype.toBuffer = function(builder, context) {
var curPos, length, _ref, _ref10, _ref11, _ref12, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9;
- if (!(this.serverName != null) || this.serverName.length === 0) {
- throw new Error('serverName not specified');
- }
if (!(this.userName != null) || this.userName.length === 0) {
throw new Error('userName not specified');
}
@@ -84,6 +87,7 @@ exports.Login7Packet = (function(_super) {
if (this.hostName == null) this.hostName = require('os').hostname();
if (this.password == null) this.password = '';
if (this.appName == null) this.appName = 'node-tds';
+ if (this.serverName == null) this.serverName = '';
if (this.interfaceLibraryName == null) this.interfaceLibraryName = 'node-tds';
if (this.language == null) this.language = '';
if (this.database == null) this.database = '';
View
6 lib/loginack.token.js
@@ -4,6 +4,12 @@ var Token,
Token = require('./token').Token;
+/**
+Token for LOGINACK (0xAD)
+
+@spec 2.2.7.11
+*/
+
exports.LoginAckToken = (function(_super) {
__extends(LoginAckToken, _super);
View
4 lib/message.token.js
@@ -6,6 +6,10 @@ TdsConstants = require('./tds-constants').TdsConstants;
Token = require('./token').Token;
+/**
+Base token for error and info message tokens
+*/
+
exports.MessageToken = (function(_super) {
__extends(MessageToken, _super);
View
4 lib/packet.js
@@ -1,4 +1,6 @@
-
+/**
+Base class for all TDS packets
+*/
exports.Packet = (function() {
function Packet() {}
View
6 lib/prelogin.packet.js
@@ -4,6 +4,12 @@ var Packet,
Packet = require('./packet').Packet;
+/**
+Packet for PRELOGIN (0x12)
+
+@spec 2.2.6.4
+*/
+
exports.PreLoginPacket = (function(_super) {
__extends(PreLoginPacket, _super);
View
6 lib/returnstatus.token.js
@@ -4,6 +4,12 @@ var Token,
Token = require('./token').Token;
+/**
+Token for RETURNSTATUS (0x79)
+
+@spec 2.2.7.15
+*/
+
exports.ReturnStatusToken = (function(_super) {
__extends(ReturnStatusToken, _super);
View
12 lib/row.token.js
@@ -6,6 +6,12 @@ TdsUtils = require('./tds-utils').TdsUtils;
Token = require('./token').Token;
+/**
+Token for ROW (0xD1)
+
+@spec 2.2.7.17
+*/
+
exports.RowToken = (function(_super) {
__extends(RowToken, _super);
@@ -57,7 +63,11 @@ exports.RowToken = (function(_super) {
var col;
col = this.metadata.getColumn(column);
if (!(col != null)) throw new Error('Column ' + column + ' not found');
- return this.values[col.index].length;
+ if (col.type.emptyPossible) {
+ return this.values[col.index].length === -1;
+ } else {
+ return this.values[col.index] === 0;
+ }
};
RowToken.prototype.getValueLength = function(column) {
View
6 lib/rpcrequest.packet.js
@@ -4,6 +4,12 @@ var Packet,
Packet = require('./packet').Packet;
+/**
+Packet for RPCRequest (0x03)
+
+@spec 2.2.6.5
+*/
+
exports.RpcRequestPacket = (function(_super) {
__extends(RpcRequestPacket, _super);
View
6 lib/sqlbatch.packet.js
@@ -4,6 +4,12 @@ var Packet,
Packet = require('./packet').Packet;
+/**
+Packet for SQLBatch (0x01)
+
+@spec 2.2.6.6
+*/
+
exports.SqlBatchPacket = (function(_super) {
__extends(SqlBatchPacket, _super);
View
4 lib/tds-client.js
@@ -27,6 +27,10 @@ TdsConstants = require('./tds-constants').TdsConstants;
TokenStreamPacket = require('./tokenstream.packet').TokenStreamPacket;
+/**
+Low level client for TDS access
+*/
+
exports.TdsClient = (function() {
function TdsClient(_handler) {
View
4 lib/tds-constants.js
@@ -1,4 +1,6 @@
-
+/**
+Class with static TDS info
+*/
exports.TdsConstants = (function() {
var i, key, value, _len, _len2, _ref, _ref2, _ref3, _ref4;
View
4 lib/tds-utils.js
@@ -1,4 +1,6 @@
-
+/**
+Common TDS utility functions
+*/
exports.TdsUtils = (function() {
function TdsUtils() {}
View
35 lib/node-tds.js → lib/tds.js
@@ -9,6 +9,10 @@ TdsClient = require('./tds-client').TdsClient;
TdsUtils = require('./tds-utils').TdsUtils;
+/**
+Connection class for connecting to SQL Server
+*/
+
exports.Connection = (function(_super) {
__extends(Connection, _super);
@@ -27,6 +31,25 @@ exports.Connection = (function(_super) {
this.connect = __bind(this.connect, this);
this._autoCommit = true;
this._client = new TdsClient({
+ error: function(err) {
+ var cb, _base;
+ if (_this._pendingCallback != null) {
+ _this._currentStatement = null;
+ cb = _this._pendingCallback;
+ _this._pendingCallback = null;
+ return cb(err);
+ } else if (_this._pendingLoginCallback != null) {
+ cb = _this._pendingLoginCallback;
+ _this._pendingLoginCallback = null;
+ return cb(err);
+ } else if (_this._currentStatement != null) {
+ return _this._currentStatement._error(err);
+ } else if (_this.handler != null) {
+ return typeof (_base = _this.handler).error === "function" ? _base.error(err) : void 0;
+ } else {
+ return _this.emit('error', err);
+ }
+ },
message: function(message) {
var cb, err, _base, _base2;
if (message.error) {
@@ -36,6 +59,10 @@ exports.Connection = (function(_super) {
cb = _this._pendingCallback;
_this._pendingCallback = null;
return cb(err);
+ } else if (_this._pendingLoginCallback != null) {
+ cb = _this._pendingLoginCallback;
+ _this._pendingLoginCallback = null;
+ return cb(err);
} else if (_this._currentStatement != null) {
return _this._currentStatement._error(err);
} else if (_this.handler != null) {
@@ -157,6 +184,10 @@ exports.Connection = (function(_super) {
})(EventEmitter);
+/**
+Statement class
+*/
+
Statement = exports.Statement = (function(_super) {
__extends(Statement, _super);
@@ -318,6 +349,10 @@ Statement = exports.Statement = (function(_super) {
})(EventEmitter);
+/**
+TdsError class
+*/
+
TdsError = exports.TdsError = (function(_super) {
__extends(TdsError, _super);
View
4 lib/token.js
@@ -1,4 +1,6 @@
-
+/**
+Base class for all tokens
+*/
exports.Token = (function() {
function Token() {}
View
6 lib/tokenstream.packet.js
@@ -20,6 +20,12 @@ ReturnStatusToken = require('./returnstatus.token').ReturnStatusToken;
RowToken = require('./row.token').RowToken;
+/**
+Packet for TokenStream (0x04)
+
+@spec 2.2.4.2
+*/
+
exports.TokenStreamPacket = (function(_super) {
__extends(TokenStreamPacket, _super);
View
23 package.json
@@ -0,0 +1,23 @@
+{
+ "name" : "tds",
+ "version" : "v0.1.0",
+ "description" : "TDS client for connecting to Microsoft SQL Server",
+ "keywords" : ["tds", "sql", "mssql", "database", "node-tds"],
+ "homepage" : "http://cretz.github.com/node-tds",
+ "author" : "Chad Retz <chad.retz@gmail.com>",
+ "main" : "./lib/tds",
+ "repository" : {
+ "type" : "git",
+ "url" : "http://github.com/cretz/node-tds.git"
+ },
+ "devDependencies" : {
+ "mocha" : ">=0.8.0"
+ },
+ "engines" : {
+ "node" : ">=0.6.0"
+ },
+ "licenses" : [{
+ "type" : "MIT",
+ "url" : "http://github.com/cretz/node-tds/raw/master/LICENSE"
+ }]
+}
View
12 src/altmetadata.token.coffee
@@ -1,15 +1,19 @@
{Token} = require './token'
+###*
+Token for ALTMETADATA (0x88)
+
+@spec 2.2.7.1
+###
class AltMetaDataToken extends Token
@type: 0x88
@name: 'ALTMETADATA'
constructor: ->
- @type = 0x88
- @name = 'ALTMETADATA'
- @handlerFunction = 'altmetadata'
+ @type = 0x88
+ @name = 'ALTMETADATA'
+ @handlerFunction = 'altmetadata'
fromBuffer: (stream, context) ->
-
#TODO
View
6 src/attention.packet.coffee
@@ -1,5 +1,11 @@
{Packet} = require './packet'
+###*
+Packet for ATTENTION (0x06). This is sent to cancel
+a query.
+
+@spec 2.2.1.6
+###
class exports.AttentionPacket extends Packet
@type: 0x06
View
5 src/buffer-builder.coffee
@@ -1,3 +1,8 @@
+
+###*
+Builder for buffers. Basically allows building a buffer
+but the buffer isn't created until toBuffer is called.
+###
class exports.BufferBuilder
@getUcs2StringLength: (string) -> string.length * 2
View
6 src/buffer-stream.coffee
@@ -1,3 +1,9 @@
+
+###*
+Streaming buffer reader. This allows you to mark the beginning
+of the read, and read individual pieces. If the underlying buffer
+isn't big enough, a StreamIndexOutOfBoundsError is thrown.
+###
class exports.BufferStream
constructor: ->
View
5 src/colmetadata.token.coffee
@@ -1,6 +1,11 @@
{Token} = require './token'
{TdsConstants} = require './tds-constants'
+###*
+Token for COLMETADATA (0x81)
+
+@spec 2.2.7.4
+###
class exports.ColMetaDataToken extends Token
@type: 0x81
View
7 src/done.token.coffee
@@ -1,6 +1,13 @@
{TdsConstants} = require './tds-constants'
{Token} = require './token'
+###*
+Token for DONE (0xFD), DONEINPROC (0xFD), and DONEPROC (0xFE)
+
+@spec 2.2.7.5
+@spec 2.2.7.6
+@spec 2.2.7.7
+###
class exports.DoneToken extends Token
@type: 0xFD
View
5 src/envchange.token.coffee
@@ -1,6 +1,11 @@
{TdsConstants} = require './tds-constants'
{Token} = require './token'
+###*
+Token for ENVCHANGE (0xE3)
+
+@spec 2.2.7.8
+###
class exports.EnvChangeToken extends Token
@type: 0xE3
View
5 src/error.message.token.coffee
@@ -1,5 +1,10 @@
{MessageToken} = require './message.token'
+###*
+Token for ERROR (0xAA)
+
+@spec 2.2.7.9
+###
class exports.ErrorMessageToken extends MessageToken
@type: 0xAA
View
5 src/info.message.token.coffee
@@ -1,5 +1,10 @@
{MessageToken} = require './message.token'
+###*
+Token for INFO (0xAB)
+
+@spec 2.2.7.10
+###
class exports.InfoMessageToken extends MessageToken
@type: 0xAB
View
7 src/login7.packet.coffee
@@ -1,6 +1,11 @@
{Packet} = require './packet'
{TdsConstants} = require './tds-constants'
+###*
+Packet for LOGIN7 (0x10). This is the packet sent for initial login
+
+@spec 2.2.6.3
+###
class exports.Login7Packet extends Packet
@type: 0x10
@@ -58,13 +63,13 @@ class exports.Login7Packet extends Packet
toBuffer: (builder, context) ->
# validate
- if not @serverName? or @serverName.length is 0 then throw new Error 'serverName not specified'
if not @userName? or @userName.length is 0 then throw new Error 'userName not specified'
if @domain? and @domain.length > 0 then throw new Error 'NTLM not yet supported'
# length
@hostName ?= require('os').hostname()
@password ?= ''
@appName ?= 'node-tds'
+ @serverName ?= ''
@interfaceLibraryName ?= 'node-tds'
@language ?= ''
@database ?= ''
View
5 src/loginack.token.coffee
@@ -1,5 +1,10 @@
{Token} = require './token'
+###*
+Token for LOGINACK (0xAD)
+
+@spec 2.2.7.11
+###
class exports.LoginAckToken extends Token
@type: 0xAD
View
3  src/message.token.coffee
@@ -1,6 +1,9 @@
{TdsConstants} = require './tds-constants'
{Token} = require './token'
+###*
+Base token for error and info message tokens
+###
class exports.MessageToken extends Token
fromBuffer: (stream, context) ->
View
4 src/packet.coffee
@@ -1,3 +1,7 @@
+
+###*
+Base class for all TDS packets
+###
class exports.Packet
@retrieveHeader: (stream, context) ->
View
5 src/prelogin.packet.coffee
@@ -1,5 +1,10 @@
{Packet} = require './packet'
+###*
+Packet for PRELOGIN (0x12)
+
+@spec 2.2.6.4
+###
class exports.PreLoginPacket extends Packet
@type: 0x12
View
5 src/returnstatus.token.coffee
@@ -1,5 +1,10 @@
{Token} = require './token'
+###*
+Token for RETURNSTATUS (0x79)
+
+@spec 2.2.7.15
+###
class exports.ReturnStatusToken extends Token
@type: 0x79
View
8 src/row.token.coffee
@@ -1,6 +1,11 @@
{TdsUtils} = require './tds-utils'
{Token} = require './token'
+###*
+Token for ROW (0xD1)
+
+@spec 2.2.7.17
+###
class exports.RowToken extends Token
@type: 0xD1
@@ -31,7 +36,8 @@ class exports.RowToken extends Token
isNull: (column) ->
col = @metadata.getColumn column
if not col? then throw new Error 'Column ' + column + ' not found'
- @values[col.index].length
+ if col.type.emptyPossible then @values[col.index].length is -1
+ else @values[col.index] is 0
getValueLength: (column) ->
col = @metadata.getColumn column
View
5 src/rpcrequest.packet.coffee
@@ -1,5 +1,10 @@
{Packet} = require './packet'
+###*
+Packet for RPCRequest (0x03)
+
+@spec 2.2.6.5
+###
class exports.RpcRequestPacket extends Packet
@type: 0x03
View
5 src/sqlbatch.packet.coffee
@@ -1,5 +1,10 @@
{Packet} = require './packet'
+###*
+Packet for SQLBatch (0x01)
+
+@spec 2.2.6.6
+###
class exports.SqlBatchPacket extends Packet
@type: 0x01
View
3  src/tds-client.coffee
@@ -13,6 +13,9 @@
{TdsConstants} = require './tds-constants'
{TokenStreamPacket} = require './tokenstream.packet'
+###*
+Low level client for TDS access
+###
class exports.TdsClient
constructor: (@_handler) ->
View
4 src/tds-constants.coffee
@@ -1,3 +1,7 @@
+
+###*
+Class with static TDS info
+###
class exports.TdsConstants
###*
View
4 src/tds-utils.coffee
@@ -1,3 +1,7 @@
+
+###*
+Common TDS utility functions
+###
class exports.TdsUtils
@buildParameterDefinition: (params, shouldAssert) ->
View
26 src/node-tds.coffee → src/tds.coffee
@@ -3,11 +3,27 @@
{TdsClient} = require './tds-client'
{TdsUtils} = require './tds-utils'
+###*
+Connection class for connecting to SQL Server
+###
class exports.Connection extends EventEmitter
constructor: (@_options) ->
@_autoCommit = true
@_client = new TdsClient
+ error: (err) =>
+ if @_pendingCallback?
+ @_currentStatement = null
+ cb = @_pendingCallback
+ @_pendingCallback = null
+ cb err
+ else if @_pendingLoginCallback?
+ cb = @_pendingLoginCallback
+ @_pendingLoginCallback = null
+ cb err
+ else if @_currentStatement? then @_currentStatement._error err
+ else if @handler? then @handler.error? err
+ else @emit 'error', err
message: (message) =>
# turn errors into actual errors
if message.error
@@ -17,6 +33,10 @@ class exports.Connection extends EventEmitter
cb = @_pendingCallback
@_pendingCallback = null
cb err
+ else if @_pendingLoginCallback?
+ cb = @_pendingLoginCallback
+ @_pendingLoginCallback = null
+ cb err
else if @_currentStatement? then @_currentStatement._error err
else if @handler? then @handler.error? err
else @emit 'error', err
@@ -102,6 +122,9 @@ class exports.Connection extends EventEmitter
@_currentStatement = null
@_client.end()
+###*
+Statement class
+###
Statement = class exports.Statement extends EventEmitter
constructor: (@_connection, @_sql, @_params, @handler) ->
@@ -214,6 +237,9 @@ Statement = class exports.Statement extends EventEmitter
if @handler? then @handler.done? done
else @emit 'done', done
+###*
+TdsError class
+###
TdsError = class exports.TdsError extends Error
constructor: (@message, @info) ->
View
3  src/token.coffee
@@ -1,3 +1,6 @@
+###*
+Base class for all tokens
+###
class exports.Token
View
5 src/tokenstream.packet.coffee
@@ -8,6 +8,11 @@
{ReturnStatusToken} = require './returnstatus.token'
{RowToken} = require './row.token'
+###*
+Packet for TokenStream (0x04)
+
+@spec 2.2.4.2
+###
class exports.TokenStreamPacket extends Packet
@type: 0x04

0 comments on commit c7d8c36

Please sign in to comment.
Something went wrong with that request. Please try again.