Comparing version 0.4.1 to 0.4.2
@@ -0,1 +1,9 @@ | ||
v0.4.2 (2014-01-06) | ||
------------------- | ||
[new] Added connection timeout for node-tds | ||
[fix] Module now handle tedious network errors correctly | ||
[fix] Connection pool now destroy failed connections correctly | ||
[fix] Connection to instance name via tedious now works correctly | ||
[change] Option 'timeout' is now common option for all drivers (see documentation) | ||
v0.4.1 (2013-12-13) | ||
@@ -2,0 +10,0 @@ ------------------- |
@@ -142,7 +142,12 @@ // Generated by CoffeeScript 1.6.3 | ||
cfg = { | ||
connectionString: (_ref1 = config.connectionString) != null ? _ref1 : 'Driver={SQL Server Native Client 11.0};Server=#{server},#{port};Database=#{database};Uid=#{user};Pwd=#{password};' | ||
connectionString: (_ref1 = config.connectionString) != null ? _ref1 : 'Driver={SQL Server Native Client 11.0};Server=#{server},#{port};Database=#{database};Uid=#{user};Pwd=#{password};Connection Timeout=#{timeout};' | ||
}; | ||
cfg.connectionString = cfg.connectionString.replace(new RegExp('#{([^}]*)}', 'g'), function(p) { | ||
var _ref2; | ||
return (_ref2 = config[p.substr(2, p.length - 3)]) != null ? _ref2 : ''; | ||
var key, _ref2, _ref3; | ||
key = p.substr(2, p.length - 3); | ||
if (key === 'timeout') { | ||
return Math.ceil(((_ref2 = config.timeout) != null ? _ref2 : 15000) / 1000); | ||
} else { | ||
return (_ref3 = config[key]) != null ? _ref3 : ''; | ||
} | ||
}); | ||
@@ -162,4 +167,7 @@ cfg_pool = { | ||
}, | ||
validate: function(c) { | ||
return c != null; | ||
}, | ||
destroy: function(c) { | ||
return c.close(); | ||
return c != null ? c.close() : void 0; | ||
} | ||
@@ -166,0 +174,0 @@ }; |
@@ -152,5 +152,15 @@ // Generated by CoffeeScript 1.6.3 | ||
create: function(callback) { | ||
var c; | ||
var c, timeouted, tmr, _ref1; | ||
c = new tds.Connection(cfg); | ||
timeouted = false; | ||
tmr = setTimeout(function() { | ||
timeouted = true; | ||
c._client._socket.destroy(); | ||
return callback(new Error("Connection timeout.", null)); | ||
}, (_ref1 = config.timeout) != null ? _ref1 : 15000); | ||
return c.connect(function(err) { | ||
clearTimeout(tmr); | ||
if (timeouted) { | ||
return; | ||
} | ||
if (err) { | ||
@@ -162,4 +172,7 @@ return callback(err, null); | ||
}, | ||
validate: function(c) { | ||
return c != null; | ||
}, | ||
destroy: function(c) { | ||
return c.end(); | ||
return c != null ? c.end() : void 0; | ||
} | ||
@@ -166,0 +179,0 @@ }; |
@@ -171,3 +171,3 @@ // Generated by CoffeeScript 1.6.3 | ||
TediousConnection.prototype.connect = function(config, callback) { | ||
var cfg, cfg_pool, key, value, _base, _base1, _ref1, | ||
var cfg, cfg_pool, key, value, _base, _base1, _base2, _ref1, _ref2, | ||
_this = this; | ||
@@ -189,2 +189,8 @@ cfg = { | ||
} | ||
if ((_base2 = cfg.options).connectTimeout == null) { | ||
_base2.connectTimeout = (_ref1 = config.timeout) != null ? _ref1 : 15000; | ||
} | ||
if (cfg.options.instanceName) { | ||
delete cfg.options.port; | ||
} | ||
cfg_pool = { | ||
@@ -196,5 +202,10 @@ name: 'mssql', | ||
create: function(callback) { | ||
var c; | ||
var c, connect, end; | ||
c = new tds.Connection(cfg); | ||
return c.once('connect', function(err) { | ||
end = function() { | ||
c.removeListener('connect', connect); | ||
return callback(new Error("Network error.", null)); | ||
}; | ||
connect = function(err) { | ||
c.removeListener('end', end); | ||
if (err) { | ||
@@ -204,12 +215,17 @@ return callback(err, null); | ||
return callback(null, c); | ||
}); | ||
}; | ||
c.once('end', end); | ||
return c.once('connect', connect); | ||
}, | ||
validate: function(c) { | ||
return c != null; | ||
}, | ||
destroy: function(c) { | ||
return c.close(); | ||
return c != null ? c.close() : void 0; | ||
} | ||
}; | ||
if (config.pool) { | ||
_ref1 = config.pool; | ||
for (key in _ref1) { | ||
value = _ref1[key]; | ||
_ref2 = config.pool; | ||
for (key in _ref2) { | ||
value = _ref2[key]; | ||
cfg_pool[key] = value; | ||
@@ -216,0 +232,0 @@ } |
@@ -19,3 +19,3 @@ { | ||
], | ||
"version": "0.4.1", | ||
"version": "0.4.2", | ||
"main": "index.js", | ||
@@ -22,0 +22,0 @@ "repository": { |
@@ -114,9 +114,11 @@ # 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) | ||
### Connection | ||
### Connections | ||
* [Connection](#connection) | ||
* [connect](#connect) | ||
* [close](#close) | ||
### Request | ||
### Requests | ||
* [Request](#request) | ||
* [execute](#execute) | ||
@@ -127,4 +129,5 @@ * [input](#input) | ||
### Transaction | ||
### Transactions | ||
* [Transaction](#transaction) | ||
* [begin](#begin) | ||
@@ -166,2 +169,3 @@ * [commit](#commit) | ||
* **database** - Database to connect to (default: dependent on server configuration). | ||
* **timeout** - Connection timeout in ms (default: 15000). | ||
* **pool.max** - The maximum number of connections there can be in the pool (default: `10`). | ||
@@ -181,3 +185,3 @@ * **pool.min** - The minimun of connections there can be in the pool (default: `0`). | ||
* **connectionString** - Connection string (default: `Driver={SQL Server Native Client 11.0};Server=#{server},#{port};Database=#{database};Uid=#{user};Pwd=#{password};`). | ||
* **connectionString** - Connection string (default: `Driver={SQL Server Native Client 11.0};Server=#{server},#{port};Database=#{database};Uid=#{user};Pwd=#{password};Connection Timeout=#{timeout};`). | ||
@@ -189,3 +193,4 @@ <a name="cfg-node-tds" /> | ||
## Connection | ||
<a name="connection" /> | ||
## Connections | ||
@@ -233,3 +238,4 @@ ```javascript | ||
## Request | ||
<a name="request" /> | ||
## Requests | ||
@@ -369,4 +375,7 @@ ```javascript | ||
## Transaction | ||
<a name="transaction" /> | ||
## Transactions | ||
**Important:** always use `Transaction` class to create transactions - it ensures that all your requests are executed on one connection. Once you call `begin`, a single connection is aquired from the connection pool and all subsequent requests (initialized with the `Transaction` object) are executed exclusively on this connection. After you call `commit` or `rollback`, connection is then released back to the connection pool. | ||
```javascript | ||
@@ -373,0 +382,0 @@ var transaction = new sql.Transaction(/* [connection] */); |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
137529
2185
596