Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mssql

Package Overview
Dependencies
Maintainers
1
Versions
170
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mssql - npm Package Compare versions

Comparing version 0.5.5 to 0.6.0

9

CHANGELOG.txt

@@ -0,1 +1,10 @@

v0.6.0 (2014-07-03)
-------------------
[change] Updated to latest Tedious 1.0.0
[new] Added support for Streaming
[new] Added option to set request timeout (config.requestTimeout = 15000)
[new] Errors documented
[change] Connection timeout renamed from config.timeout to config.connectionTimeout
[fix] Minor bug fixes
v0.5.5 (2014-06-24)

@@ -2,0 +11,0 @@ -------------------

2

lib/datatypes.js

@@ -210,3 +210,3 @@ // Generated by CoffeeScript 1.7.1

case TYPES.Numeric:
return "" + ((_ref2 = type.precision) != null ? _ref2 : 18) + " (" + ((_ref3 = options.scale) != null ? _ref3 : 0) + ")";
return "" + type.declaration + " (" + ((_ref2 = type.precision) != null ? _ref2 : 18) + ", " + ((_ref3 = options.scale) != null ? _ref3 : 0) + ")";
case TYPES.Time:

@@ -213,0 +213,0 @@ case TYPES.DateTime2:

@@ -150,3 +150,3 @@ // Generated by CoffeeScript 1.7.1

function Connection(config, callback) {
var err, _base, _base1, _base2, _ref1;
var err, _base, _base1, _base2, _base3, _ref1;
this.config = config;

@@ -162,2 +162,5 @@ if ((_base = this.config).driver == null) {

}
if ((_base3 = this.config).stream == null) {
_base3.stream = false;
}
if (/^(.*)\\(.*)$/.exec(this.config.server)) {

@@ -440,3 +443,3 @@ this.config.server = RegExp.$1;

if (typeof callback === "function") {
callback(new PreparedStatementError("Statement is already prepared."));
callback(new PreparedStatementError("Statement is already prepared.", 'EALREADYPREPARED'));
}

@@ -490,3 +493,3 @@ return this;

if (typeof callback === "function") {
callback(new PreparedStatementError("Transaction has not started. Call begin() first."));
callback(new TransactionError("Transaction has not begun. Call begin() first.", 'ENOTBEGUN'));
}

@@ -532,3 +535,3 @@ return this;

if (!this._pooledConnection) {
callback(new PreparedStatementError("Statement is not prepared. Call prepare() first."));
callback(new PreparedStatementError("Statement is not prepared. Call prepare() first.", 'ENOTPREPARED'));
return this;

@@ -596,3 +599,3 @@ }

if (typeof callback === "function") {
callback(new PreparedStatementError("Statement is not prepared. Call prepare() first."));
callback(new PreparedStatementError("Statement is not prepared. Call prepare() first.", 'ENOTPREPARED'));
}

@@ -686,3 +689,3 @@ return this;

if (typeof callback === "function") {
callback(new TransactionError("Transaction is already running."));
callback(new TransactionError("Transaction has already begun.", 'EALREADYBEGUN'));
}

@@ -714,3 +717,3 @@ return this;

if (typeof callback === "function") {
callback(new TransactionError("Transaction has not started. Call begin() first."));
callback(new TransactionError("Transaction has not begun. Call begin() first.", 'ENOTBEGUN'));
}

@@ -721,3 +724,3 @@ return this;

if (typeof callback === "function") {
callback(new TransactionError("Can't commit transaction. There is a request in progress."));
callback(new TransactionError("Can't commit transaction. There is a request in progress.", 'EREQINPROG'));
}

@@ -767,3 +770,3 @@ return this;

if (!this._pooledConnection) {
callback(new TransactionError("Transaction has not started. Call begin() first."));
callback(new TransactionError("Transaction has not begun. Call begin() first.", 'ENOTBEGUN'));
return this;

@@ -803,3 +806,3 @@ }

if (typeof callback === "function") {
callback(new TransactionError("Transaction has not started. Call begin() first."));
callback(new TransactionError("Transaction has not begun. Call begin() first.", 'ENOTBEGUN'));
}

@@ -810,3 +813,3 @@ return this;

if (typeof callback === "function") {
callback(new TransactionError("Can't rollback transaction. There is a request in progress."));
callback(new TransactionError("Can't rollback transaction. There is a request in progress.", 'EREQINPROG'));
}

@@ -841,5 +844,6 @@ return this;

@event recordset Dispatched when new recordset is parsed (with all rows).
@event recordset Dispatched when metadata for new recordset are parsed.
@event row Dispatched when new row is parsed.
@event done Dispatched when request is complete.
@event error Dispatched on error.
*/

@@ -864,3 +868,5 @@

Request.prototype.stream = null;
/*

@@ -911,2 +917,5 @@ Log to a function if assigned. Else, use console.log.

} else {
if (!this.connection.pool) {
return callback(new ConnectionError("Connection not yet open.", 'ENOTOPEN'));
}
return this.connection.pool.acquire(callback);

@@ -1063,13 +1072,29 @@ }

if (!this.connection) {
return process.nextTick(function() {
return typeof callback === "function" ? callback(new RequestError("No connection is specified for that request.", 'ENOCONN')) : void 0;
});
return process.nextTick((function(_this) {
return function() {
var e;
e = new RequestError("No connection is specified for that request.", 'ENOCONN');
if (_this.stream) {
_this.emit('error', e);
return _this.emit('done');
} else {
return typeof callback === "function" ? callback(e) : void 0;
}
};
})(this));
}
this.canceled = false;
if (this.stream == null) {
this.stream = this.connection.config.stream;
}
this.connection.driver.Request.prototype.query.call(this, command, (function(_this) {
return function(err, recordset) {
if (!err) {
_this.emit('done', err, recordset);
if (_this.stream) {
if (err) {
_this.emit('error', err);
}
return _this.emit('done');
} else {
return typeof callback === "function" ? callback(err, recordset) : void 0;
}
return typeof callback === "function" ? callback(err, recordset) : void 0;
};

@@ -1113,10 +1138,26 @@ })(this));

return process.nextTick(function() {
return typeof callback === "function" ? callback(new RequestError("No connection is specified for that request.", 'ENOCONN')) : void 0;
var e;
e = new RequestError("No connection is specified for that request.", 'ENOCONN');
if (this.stream) {
this.emit('error', e);
return this.emit('done');
} else {
return typeof callback === "function" ? callback(e) : void 0;
}
});
}
this.canceled = false;
if (this.stream == null) {
this.stream = this.connection.config.stream;
}
this.connection.driver.Request.prototype.execute.call(this, procedure, (function(_this) {
return function(err, recordsets, returnValue) {
_this.emit('done', err, recordsets);
return typeof callback === "function" ? callback(err, recordsets, returnValue) : void 0;
if (_this.stream) {
if (err) {
_this.emit('error', err);
}
return _this.emit('done', returnValue);
} else {
return typeof callback === "function" ? callback(err, recordsets, returnValue) : void 0;
}
};

@@ -1123,0 +1164,0 @@ })(this));

@@ -412,8 +412,7 @@ // Generated by CoffeeScript 1.7.1

if (row["___return___"] == null) {
_this.emit('row', row);
if (_this.stream) {
_this.emit('row', row);
}
}
}
if (recordset) {
_this.emit('recordset', recordset);
}
row = null;

@@ -426,3 +425,9 @@ columns = metadata;

});
return recordsets.push(recordset);
if (_this.stream) {
if (recordset.columns["___return___"] == null) {
return _this.emit('recordset', recordset.columns);
}
} else {
return recordsets.push(recordset);
}
});

@@ -436,7 +441,11 @@ req.on('row', function(rownumber) {

if (row["___return___"] == null) {
_this.emit('row', row);
if (_this.stream) {
_this.emit('row', row);
}
}
}
row = {};
return recordset.push(row);
if (!_this.stream) {
return recordset.push(row);
}
});

@@ -470,10 +479,12 @@ req.on('column', function(idx, data, more) {

if (!_this.nested) {
if (recordset) {
_this.emit('recordset', recordset);
}
if (_this.verbose) {
if (row) {
if (row) {
if (_this.verbose) {
_this.doLog(util.inspect(row));
_this.doLog("---------- --------------------");
}
if (row["___return___"] == null) {
if (_this.stream) {
_this.emit('row', row);
}
}
}

@@ -501,3 +512,7 @@ if (handleOutput) {

_this._release(connection);
return typeof callback === "function" ? callback(null, _this.multiple || _this.nested ? recordsets : recordsets[0]) : void 0;
if (_this.stream) {
return callback(null, _this.nested ? row : null);
} else {
return typeof callback === "function" ? callback(null, _this.multiple || _this.nested ? recordsets : recordsets[0]) : void 0;
}
});

@@ -576,3 +591,7 @@ } else {

} else {
last = (_ref2 = recordsets.pop()) != null ? _ref2[0] : void 0;
if (_this.stream) {
last = recordsets;
} else {
last = (_ref2 = recordsets.pop()) != null ? _ref2[0] : void 0;
}
if (last && (last.___return___ != null)) {

@@ -598,4 +617,8 @@ returnValue = last.___return___;

}
recordsets.returnValue = returnValue;
return typeof callback === "function" ? callback(null, recordsets, returnValue) : void 0;
if (_this.stream) {
return callback(null, null, returnValue);
} else {
recordsets.returnValue = returnValue;
return typeof callback === "function" ? callback(null, recordsets, returnValue) : void 0;
}
}

@@ -602,0 +625,0 @@ };

@@ -219,3 +219,3 @@ // Generated by CoffeeScript 1.7.1

c._client._socket.destroy();
return callback(new ConnectionError("Connection timeout.", null));
return callback(new ConnectionError("Connection timeout.", 'ETIMEOUT'), null);
}, (_ref1 = config.timeout) != null ? _ref1 : 15000);

@@ -344,3 +344,3 @@ return c.connect(function(err) {

TDSRequest.prototype.query = function(command, callback) {
var columns, errors, handleOutput, input, name, output, param, paramHeaders, paramValues, recordset, recordsets, started, _ref1;
var errors, handleOutput, input, lastrow, name, output, param, paramHeaders, paramValues, recordset, recordsets, started, _ref1;
if (this.verbose && !this.nested) {

@@ -361,3 +361,2 @@ this.doLog("---------- sql query ----------\n query: " + command);

}
columns = null;
recordset = null;

@@ -368,2 +367,3 @@ recordsets = [];

errors = [];
lastrow = null;
paramHeaders = {};

@@ -446,11 +446,13 @@ paramValues = {};

if (row["___return___"] == null) {
_this.emit('row', row);
if (_this.stream) {
_this.emit('row', row);
}
} else {
lastrow = row;
}
return recordset.push(row);
if (!_this.stream) {
return recordset.push(row);
}
});
req.on('metadata', function(metadata) {
if (recordset) {
_this.emit('recordset', recordset);
}
columns = metadata.columnsByName;
recordset = [];

@@ -461,3 +463,9 @@ Object.defineProperty(recordset, 'columns', {

}, _this.nested);
return recordsets.push(recordset);
if (_this.stream) {
if (recordset.columns["___return___"] == null) {
return _this.emit('recordset', recordset.columns);
}
} else {
return recordsets.push(recordset);
}
});

@@ -467,5 +475,2 @@ req.on('done', function(res) {

if (!_this.nested) {
if (recordset) {
_this.emit('recordset', recordset);
}
if (handleOutput) {

@@ -497,3 +502,3 @@ last = (_ref2 = recordsets.pop()) != null ? _ref2[0] : void 0;

}
if (errors.length) {
if (errors.length && !_this.stream) {
error = errors.pop();

@@ -503,6 +508,16 @@ error.precedingErrors = errors;

_this._release(connection);
return typeof callback === "function" ? callback(error, _this.multiple || _this.nested ? recordsets : recordsets[0]) : void 0;
if (_this.stream) {
return callback(null, _this.nested ? lastrow : null);
} else {
return typeof callback === "function" ? callback(error, _this.multiple || _this.nested ? recordsets : recordsets[0]) : void 0;
}
});
req.on('error', function(err) {
return errors.push(RequestError(err));
var e;
e = RequestError(err, 'EREQUEST');
if (_this.stream) {
return _this.emit('error', e);
} else {
return errors.push(e);
}
});

@@ -582,3 +597,7 @@ return req.execute(paramValues);

} else {
last = (_ref2 = recordsets.pop()) != null ? _ref2[0] : void 0;
if (_this.stream) {
last = recordsets;
} else {
last = (_ref2 = recordsets.pop()) != null ? _ref2[0] : void 0;
}
if (last && (last.___return___ != null)) {

@@ -604,4 +623,8 @@ returnValue = last.___return___;

}
recordsets.returnValue = returnValue;
return typeof callback === "function" ? callback(null, recordsets, returnValue) : void 0;
if (_this.stream) {
return callback(null, null, returnValue);
} else {
recordsets.returnValue = returnValue;
return typeof callback === "function" ? callback(null, recordsets, returnValue) : void 0;
}
}

@@ -608,0 +631,0 @@ };

@@ -267,3 +267,3 @@ // Generated by CoffeeScript 1.7.1

TediousConnection.prototype.connect = function(config, callback) {
var cfg, cfg_pool, key, value, _base, _base1, _base2, _base3, _ref, _ref1;
var cfg, cfg_pool, key, value, _base, _base1, _base2, _base3, _base4, _ref, _ref1, _ref2, _ref3;
cfg = {

@@ -282,7 +282,10 @@ userName: config.user,

if ((_base2 = cfg.options).connectTimeout == null) {
_base2.connectTimeout = (_ref = config.timeout) != null ? _ref : 15000;
_base2.connectTimeout = (_ref = (_ref1 = config.connectionTimeout) != null ? _ref1 : config.timeout) != null ? _ref : 15000;
}
if ((_base3 = cfg.options).tdsVersion == null) {
_base3.tdsVersion = '7_4';
if ((_base3 = cfg.options).requestTimeout == null) {
_base3.requestTimeout = (_ref2 = config.requestTimeout) != null ? _ref2 : 15000;
}
if ((_base4 = cfg.options).tdsVersion == null) {
_base4.tdsVersion = '7_4';
}
cfg.options.rowCollectionOnDone = false;

@@ -322,5 +325,5 @@ cfg.options.rowCollectionOnRequestCompletion = false;

if (config.pool) {
_ref1 = config.pool;
for (key in _ref1) {
value = _ref1[key];
_ref3 = config.pool;
for (key in _ref3) {
value = _ref3[key];
cfg_pool[key] = value;

@@ -430,5 +433,12 @@ }

errors = [];
handleError = function(err) {
return errors.push(new RequestError(err.message, 'EREQUEST'));
};
handleError = (function(_this) {
return function(err) {
var e;
e = new RequestError(err.message, 'EREQUEST');
if (_this.stream) {
_this.emit('error', e);
}
return errors.push(e);
};
})(this);
return this._acquire((function(_this) {

@@ -458,3 +468,7 @@ return function(err, connection) {

if (err && err.message !== ((_ref = errors[errors.length - 1]) != null ? _ref.message : void 0)) {
errors.push(RequestError(err));
err = RequestError(err);
if (_this.stream) {
_this.emit('error', err);
}
errors.push(err);
}

@@ -472,10 +486,4 @@ if (_this.verbose) {

}
if (recordset) {
Object.defineProperty(recordset, 'columns', {
enumerable: false,
value: columns
});
}
_this._cancel = null;
if (errors.length) {
if (errors.length && !_this.stream) {
error = errors.pop();

@@ -486,12 +494,18 @@ error.precedingErrors = errors;

_this._release(connection);
return typeof callback === "function" ? callback(error, _this.multiple ? recordsets : recordsets[0]) : void 0;
if (_this.stream) {
return callback(null, null);
} else {
return typeof callback === "function" ? callback(error, _this.multiple ? recordsets : recordsets[0]) : void 0;
}
});
req.on('columnMetadata', function(metadata) {
var col, _i, _len, _results;
_results = [];
var col, _i, _len;
for (_i = 0, _len = metadata.length; _i < _len; _i++) {
col = metadata[_i];
_results.push(columns[col.colName] = col);
columns[col.colName] = col;
}
return _results;
columns = createColumns(columns);
if (_this.stream) {
return _this.emit('recordset', columns);
}
});

@@ -504,3 +518,3 @@ req.on('doneInProc', function(rowCount, more, rows) {

enumerable: false,
value: createColumns(columns)
value: columns
});

@@ -513,4 +527,5 @@ Object.defineProperty(recordset, 'toTable', {

});
_this.emit('recordset', recordset);
recordsets.push(recordset);
if (!_this.stream) {
recordsets.push(recordset);
}
recordset = [];

@@ -554,3 +569,5 @@ return columns = {};

_this.emit('row', row);
return recordset.push(row);
if (!_this.stream) {
return recordset.push(row);
}
});

@@ -614,5 +631,12 @@ _ref = _this.parameters;

errors = [];
handleError = function(err) {
return errors.push(new RequestError(err.message, 'EREQUEST'));
};
handleError = (function(_this) {
return function(err) {
var e;
e = new RequestError(err.message, 'EREQUEST');
if (_this.stream) {
_this.emit('error', e);
}
return errors.push(e);
};
})(this);
return this._acquire((function(_this) {

@@ -642,3 +666,7 @@ return function(err, connection) {

if (err && err.message !== ((_ref = errors[errors.length - 1]) != null ? _ref.message : void 0)) {
errors.push(RequestError(err));
err = RequestError(err);
if (_this.stream) {
_this.emit('error', err);
}
errors.push(err);
}

@@ -658,3 +686,3 @@ if (_this.verbose) {

_this._cancel = null;
if (errors.length) {
if (errors.length && !_this.stream) {
error = errors.pop();

@@ -665,13 +693,19 @@ error.precedingErrors = errors;

_this._release(connection);
recordsets.returnValue = returnValue;
return typeof callback === "function" ? callback(error, recordsets, returnValue) : void 0;
if (_this.stream) {
return callback(null, null, returnValue);
} else {
recordsets.returnValue = returnValue;
return typeof callback === "function" ? callback(error, recordsets, returnValue) : void 0;
}
});
req.on('columnMetadata', function(metadata) {
var col, _i, _len, _results;
_results = [];
var col, _i, _len;
for (_i = 0, _len = metadata.length; _i < _len; _i++) {
col = metadata[_i];
_results.push(columns[col.colName] = col);
columns[col.colName] = col;
}
return _results;
columns = createColumns(columns);
if (_this.stream) {
return _this.emit('recordset', columns);
}
});

@@ -703,3 +737,5 @@ req.on('row', function(columns) {

_this.emit('row', row);
return recordset.push(row);
if (!_this.stream) {
return recordset.push(row);
}
});

@@ -712,3 +748,3 @@ req.on('doneInProc', function(rowCount, more, rows) {

enumerable: false,
value: createColumns(columns)
value: columns
});

@@ -721,4 +757,5 @@ Object.defineProperty(recordset, 'toTable', {

});
_this.emit('recordset', recordset);
recordsets.push(recordset);
if (!_this.stream) {
recordsets.push(recordset);
}
recordset = [];

@@ -731,5 +768,2 @@ return columns = {};

req.on('returnValue', function(parameterName, value, metadata) {
if (metadata.type === tds.TYPES.Binary || metadata.type === tds.TYPES.VarBinary || metadata.type === tds.TYPES.Image) {
value = new Buffer(value);
}
if (_this.verbose) {

@@ -736,0 +770,0 @@ if (value === tds.TYPES.Null) {

@@ -20,3 +20,3 @@ {

],
"version": "0.5.5",
"version": "0.6.0",
"main": "index.js",

@@ -34,8 +34,8 @@ "repository": {

"dependencies": {
"tedious": "0.2.4",
"generic-pool": "2.0.4"
"tedious": "^1.0.0",
"generic-pool": "^2.0.4"
},
"devDependencies": {
"coffee-script": "1.7.1",
"mocha": "1.12.0"
"coffee-script": "^1.7.1",
"mocha": "^1.12.0"
},

@@ -42,0 +42,0 @@ "engines": {

@@ -21,27 +21,8 @@ # node-mssql [![Dependency Status](https://david-dm.org/patriksimek/node-mssql.png)](https://david-dm.org/patriksimek/node-mssql) [![NPM version](https://badge.fury.io/js/mssql.png)](http://badge.fury.io/js/mssql)

## What's new in 0.5.5 (stable, npm)
## What's new in 0.6.0 (stable, npm)
- Fix: Failed login left open connection pool
- Updated to latest Tedious 1.0.0
- Added support for [Streaming](#streaming)
- Added option to set request timeout (`config.requestTimeout = 15000`)
## What's new in 0.5.x
- Updated to new Tedious 0.2.2
- Added support for TDS 7.4
- Added request cancelation
- Added support for UDT, TVP, Time, Date, DateTime2 and DateTimeOffset data types
- Numeric, Decimal, SmallMoney and Money are now supported as input parameters
- Fixed compatibility with TDS 7.1 (SQL Server 2000)
- Minor fixes
- You can now easily set up types' length/scale (`sql.VarChar(50)`)
- Serialization of [Geography and Geometry](#geography) CLR types
- Support for creating [Table-Value Parameters](#tvp) (`var tvp = new sql.Table()`)
- Output parameters are now Input-Output and can handle initial value
- Option to choose whether to pass/receive times in UTC or local time
- Connecting to named instances simplified
- Default SQL data type for JS String type is now NVarChar (was VarChar)
- Support for [Prepared Statements](#prepared-statement)
- Fixed order of output parameters
- Minor fixes in node-tds driver
- Multiple errors handling (`err.precedingErrors`)
## Installation

@@ -177,2 +158,3 @@

* [Streaming](#streaming)
* [Geography and Geometry](#geography)

@@ -211,3 +193,5 @@ * [Table-Valued Parameter](#tvp)

- **database** - Database to connect to (default: dependent on server configuration).
- **timeout** - Connection timeout in ms (default: `15000`).
- **connectionTimeout** - Connection timeout in ms (default: `15000`).
- **requestTimeout** - Request timeout in ms (default: `15000`).
- **stream** - Stream recordsets/rows instead of returning them all at once as an argument of callback (default: `false`). You can also enable streaming for each request independently (`request.stream = true`). Always set to `true` if you plan to work with large amount of rows.
- **pool.max** - The maximum number of connections there can be in the pool (default: `10`).

@@ -261,2 +245,5 @@ - **pool.min** - The minimun of connections there can be in the pool (default: `0`).

__Errors__
- EDRIVER (`ConnectionError`) - Unknown driver.
### Events

@@ -293,2 +280,10 @@

__Errors__
- ELOGIN (`ConnectionError`) - Login failed.
- ETIMEOUT (`ConnectionError`) - Connection timeout.
- EALREADYCONNECTED (`ConnectionError`) - Database is already connected!
- EALREADYCONNECTING (`ConnectionError`) - Already connecting to database!
- EINSTLOOKUP (`ConnectionError`) - Instance lookup failed.
- ESOCKET (`ConnectionError`) - Socket error.
---------------------------------------

@@ -318,5 +313,6 @@

- **recordset(recordset)** - Dispatched when new recordset is parsed (and all its rows).
- **recordset(columns)** - Dispatched when metadata for new recordset are parsed.
- **row(row)** - Dispatched when new row is parsed.
- **done(err, recordsets)** - Dispatched when request is complete.
- **done(returnValue)** - Dispatched when request is complete.
- **error(err)** - Dispatched on error.

@@ -355,2 +351,10 @@ ---------------------------------------

__Errors__
- EREQUEST (`RequestError`) - *Message from SQL Server*
- ECANCEL (`RequestError`) - Canceled.
- ETIMEOUT (`RequestError`) - Request timeout.
- ENOCONN (`RequestError`) - No connection is specified for that request.
- ENOTOPEN (`ConnectionError`) - Connection not yet open.
- ENOTBEGUN (`TransactionError`) - Transaction has not begun.
---------------------------------------

@@ -399,2 +403,5 @@

__Errors__
- EARGS (`RequestError`) - Invalid number of arguments.
---------------------------------------

@@ -445,2 +452,10 @@

__Errors__
- ETIMEOUT (`RequestError`) - Request timeout.
- EREQUEST (`RequestError`) - *Message from SQL Server*
- ECANCEL (`RequestError`) - Canceled.
- ENOCONN (`RequestError`) - No connection is specified for that request.
- ENOTOPEN (`ConnectionError`) - Connection not yet open.
- ENOTBEGUN (`TransactionError`) - Transaction has not begun.
You can enable multiple recordsets in queries with the `request.multiple = true` command.

@@ -542,2 +557,6 @@

__Errors__
- ENOTOPEN (`ConnectionError`) - Connection not yet open.
- EALREADYBEGUN (`TransactionError`) - Transaction has already begun.
---------------------------------------

@@ -567,2 +586,6 @@

__Errors__
- ENOTBEGUN (`TransactionError`) - Transaction has not begun.
- EREQINPROG (`TransactionError`) - Can't commit transaction. There is a request in progress.
---------------------------------------

@@ -592,2 +615,6 @@

__Errors__
- ENOTBEGUN (`TransactionError`) - Transaction has not begun.
- EREQINPROG (`TransactionError`) - Can't rollback transaction. There is a request in progress.
<a name="prepared-statement" />

@@ -646,2 +673,5 @@ ## PreparedStatement

__Errors__
- EARGS (`PreparedStatementError`) - Invalid number of arguments.
---------------------------------------

@@ -666,2 +696,5 @@

__Errors__
- EARGS (`PreparedStatementError`) - Invalid number of arguments.
---------------------------------------

@@ -688,2 +721,7 @@

__Errors__
- ENOTOPEN (`ConnectionError`) - Connection not yet open.
- EALREADYPREPARED (`PreparedStatementError`) - Statement is already prepared.
- ENOTBEGUN (`TransactionError`) - Transaction has not started.
---------------------------------------

@@ -734,2 +772,5 @@

__Errors__
- ENOTPREPARED (`PreparedStatementError`) - Statement is not prepared.
---------------------------------------

@@ -761,2 +802,36 @@

__Errors__
- ENOTPREPARED (`PreparedStatementError`) - Statement is not prepared.
<a name="streaming" />
## Streaming
If you plan to work with large amount of rows, you should always use streaming. Once you enable this, you must listen for events to receive data.
```javascript
sql.connect(config, function(err) {
// ... error checks
var request = new sql.Request();
request.stream = true; // You can set streaming differently for each request
request.query('select * from verylargetable'); // or request.execute(procedure);
request.on('recordset', function(columns) {
// Emitted once for each recordset in a query
});
request.on('row', function(row) {
// Emitted for each row in a recordset
});
request.on('error', function(err) {
// May be emitted multiple times
});
request.on('done', function(returnValue) {
// Always emitted as the last one
});
});
```
<a name="geography" />

@@ -796,3 +871,3 @@ ## Geography and Geometry

Supported on SQL Server 2008 and later. Not supported by optional drivers `msnodesql` and `tds`. You can pass a data table as a parameter to stored procedure. First, we have to create custom type in our database.
Supported on SQL Server 2008 and later. You can pass a data table as a parameter to stored procedure. First, we have to create custom type in our database.

@@ -850,2 +925,28 @@ ```sql

### Error Codes
Each known error has `code` property.
Type | Code | Description
:--- | :--- | :---
`ConnectionError` | ELOGIN | Login failed.
`ConnectionError` | ETIMEOUT | Connection timeout.
`ConnectionError` | EDRIVER | Unknown driver.
`ConnectionError` | EALREADYCONNECTED | Database is already connected!
`ConnectionError` | EALREADYCONNECTING | Already connecting to database!
`ConnectionError` | ENOTOPEN | Connection not yet open.
`ConnectionError` | EINSTLOOKUP | Instance lookup failed.
`ConnectionError` | ESOCKET | Scoket error.
`TransactionError` | ENOTBEGUN | Transaction has not begun.
`TransactionError` | EALREADYBEGUN | Transaction has already begun.
`TransactionError` | EREQINPROG | Can't commit/rollback transaction. There is a request in progress.
`RequestError` | EREQUEST | *Message from SQL Server*
`RequestError` | ECANCEL | Canceled.
`RequestError` | ETIMEOUT | Request timeout.
`RequestError` | EARGS | Invalid number of arguments.
`RequestError` | ENOCONN | No connection is specified for that request.
`PreparedStatementError` | EARGS | Invalid number of arguments.
`PreparedStatementError` | EALREADYPREPARED | Statement is already prepared.
`PreparedStatementError` | ENOTPREPARED | Statement is not prepared.
<a name="meta" />

@@ -981,2 +1082,4 @@ ## Metadata

- msnodesql 0.2.1 contains bug in DateTimeOffset ([reported](https://github.com/WindowsAzure/node-sqlserver/issues/160))
- msnodesql 0.2.1 doesn't support TVP data type.
- msnodesql 0.2.1 doesn't support request timeout.

@@ -992,2 +1095,5 @@ ### node-tds

- node-tds 0.1.0 always return date/time values in local time.
- node-tds 0.1.0 has serious problems with MAX types.
- node-tds 0.1.0 doesn't support TVP data type.
- node-tds 0.1.0 doesn't support request timeout.

@@ -994,0 +1100,0 @@ <a name="license" />

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc