Comparing version 2.1.2 to 2.1.3
@@ -0,1 +1,5 @@ | ||
v2.1.3 (2015-05-03) | ||
------------------- | ||
[fix] msnodesql: Release connection to pool on query error (Farhan Khan) | ||
v2.1.2 (2015-03-28) | ||
@@ -2,0 +6,0 @@ ------------------- |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.9.0 | ||
// Generated by CoffeeScript 1.9.2 | ||
(function() { | ||
@@ -3,0 +3,0 @@ var buffer, cfgPath, config, ex, fs, path, sql, write; |
@@ -1,4 +0,4 @@ | ||
// Generated by CoffeeScript 1.9.0 | ||
// Generated by CoffeeScript 1.9.2 | ||
(function() { | ||
var TYPES, key, value, zero, _fn; | ||
var TYPES, fn, key, value, zero; | ||
@@ -186,3 +186,3 @@ TYPES = { | ||
_fn = function(key, value) { | ||
fn = function(key, value) { | ||
return value.inspect = function() { | ||
@@ -196,7 +196,7 @@ return "[sql." + key + "]"; | ||
module.exports.DECLARATIONS[value.declaration] = value; | ||
_fn(key, value); | ||
fn(key, value); | ||
} | ||
module.exports.declare = function(type, options) { | ||
var _ref, _ref1, _ref2, _ref3, _ref4, _ref5; | ||
var ref, ref1, ref2, ref3, ref4, ref5; | ||
switch (type) { | ||
@@ -206,16 +206,16 @@ case TYPES.VarChar: | ||
case TYPES.VarBinary: | ||
return type.declaration + " (" + (options.length > 8000 ? 'MAX' : (_ref = options.length) != null ? _ref : 'MAX') + ")"; | ||
return type.declaration + " (" + (options.length > 8000 ? 'MAX' : (ref = options.length) != null ? ref : 'MAX') + ")"; | ||
case TYPES.NVarChar: | ||
return type.declaration + " (" + (options.length > 4000 ? 'MAX' : (_ref1 = options.length) != null ? _ref1 : 'MAX') + ")"; | ||
return type.declaration + " (" + (options.length > 4000 ? 'MAX' : (ref1 = options.length) != null ? ref1 : 'MAX') + ")"; | ||
case TYPES.Char: | ||
case TYPES.NChar: | ||
case TYPES.Binary: | ||
return type.declaration + " (" + ((_ref2 = options.length) != null ? _ref2 : 1) + ")"; | ||
return type.declaration + " (" + ((ref2 = options.length) != null ? ref2 : 1) + ")"; | ||
case TYPES.Decimal: | ||
case TYPES.Numeric: | ||
return type.declaration + " (" + ((_ref3 = options.precision) != null ? _ref3 : 18) + ", " + ((_ref4 = options.scale) != null ? _ref4 : 0) + ")"; | ||
return type.declaration + " (" + ((ref3 = options.precision) != null ? ref3 : 18) + ", " + ((ref4 = options.scale) != null ? ref4 : 0) + ")"; | ||
case TYPES.Time: | ||
case TYPES.DateTime2: | ||
case TYPES.DateTimeOffset: | ||
return type.declaration + " (" + ((_ref5 = options.scale) != null ? _ref5 : 7) + ")"; | ||
return type.declaration + " (" + ((ref5 = options.scale) != null ? ref5 : 7) + ")"; | ||
case TYPES.TVP: | ||
@@ -229,3 +229,3 @@ return options.tvpType + " readonly"; | ||
module.exports.cast = function(value, type, options) { | ||
var ns, scale, _ref; | ||
var ns, ref, scale; | ||
if (value == null) { | ||
@@ -251,3 +251,3 @@ return null; | ||
} | ||
scale = (_ref = options.scale) != null ? _ref : 7; | ||
scale = (ref = options.scale) != null ? ref : 7; | ||
if (scale > 0) { | ||
@@ -271,3 +271,3 @@ ns = String(ns).substr(1, scale + 1); | ||
zero = function(value, length) { | ||
var i, _i, _ref; | ||
var i, j, ref; | ||
if (length == null) { | ||
@@ -278,3 +278,3 @@ length = 2; | ||
if (value.length < length) { | ||
for (i = _i = 1, _ref = length - value.length; 1 <= _ref ? _i <= _ref : _i >= _ref; i = 1 <= _ref ? ++_i : --_i) { | ||
for (i = j = 1, ref = length - value.length; 1 <= ref ? j <= ref : j >= ref; i = 1 <= ref ? ++j : --j) { | ||
value = "0" + value; | ||
@@ -281,0 +281,0 @@ } |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.9.0 | ||
// Generated by CoffeeScript 1.9.2 | ||
(function() { | ||
@@ -3,0 +3,0 @@ module.exports = { |
162
lib/main.js
@@ -1,8 +0,8 @@ | ||
// Generated by CoffeeScript 1.9.0 | ||
// Generated by CoffeeScript 1.9.2 | ||
(function() { | ||
var Connection, ConnectionError, DRIVERS, EventEmitter, ISOLATION_LEVEL, PreparedStatement, PreparedStatementError, Request, RequestError, TYPES, Table, Transaction, TransactionError, declare, fs, getTypeByValue, global_connection, key, map, util, value, _ref, _ref1, | ||
__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; }, | ||
__hasProp = {}.hasOwnProperty, | ||
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }, | ||
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; | ||
var Connection, ConnectionError, DRIVERS, EventEmitter, ISOLATION_LEVEL, PreparedStatement, PreparedStatementError, Request, RequestError, TYPES, Table, Transaction, TransactionError, declare, fs, getTypeByValue, global_connection, key, map, ref, ref1, util, value, | ||
extend = 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; }, | ||
hasProp = {}.hasOwnProperty, | ||
indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }, | ||
bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; | ||
@@ -15,3 +15,3 @@ EventEmitter = require('events').EventEmitter; | ||
_ref = require('./datatypes'), TYPES = _ref.TYPES, declare = _ref.declare; | ||
ref = require('./datatypes'), TYPES = ref.TYPES, declare = ref.declare; | ||
@@ -47,4 +47,4 @@ ISOLATION_LEVEL = require('./isolationlevel'); | ||
map.register = function(jstype, sqltype) { | ||
var index, item, _i, _len; | ||
for (index = _i = 0, _len = this.length; _i < _len; index = ++_i) { | ||
var i, index, item, len; | ||
for (index = i = 0, len = this.length; i < len; index = ++i) { | ||
item = this[index]; | ||
@@ -82,3 +82,3 @@ if (!(item.js === jstype)) { | ||
getTypeByValue = function(value) { | ||
var item, _i, _j, _k, _l, _len, _len1, _len2, _len3; | ||
var i, item, j, k, l, len, len1, len2, len3; | ||
if (value === null || value === void 0) { | ||
@@ -89,4 +89,4 @@ return TYPES.NVarChar; | ||
case 'string': | ||
for (_i = 0, _len = map.length; _i < _len; _i++) { | ||
item = map[_i]; | ||
for (i = 0, len = map.length; i < len; i++) { | ||
item = map[i]; | ||
if (item.js === String) { | ||
@@ -98,4 +98,4 @@ return item.sql; | ||
case 'number': | ||
for (_j = 0, _len1 = map.length; _j < _len1; _j++) { | ||
item = map[_j]; | ||
for (j = 0, len1 = map.length; j < len1; j++) { | ||
item = map[j]; | ||
if (item.js === Number) { | ||
@@ -107,4 +107,4 @@ return item.sql; | ||
case 'boolean': | ||
for (_k = 0, _len2 = map.length; _k < _len2; _k++) { | ||
item = map[_k]; | ||
for (k = 0, len2 = map.length; k < len2; k++) { | ||
item = map[k]; | ||
if (item.js === Boolean) { | ||
@@ -116,4 +116,4 @@ return item.sql; | ||
case 'object': | ||
for (_l = 0, _len3 = map.length; _l < _len3; _l++) { | ||
item = map[_l]; | ||
for (l = 0, len3 = map.length; l < len3; l++) { | ||
item = map[l]; | ||
if (value instanceof item.js) { | ||
@@ -141,4 +141,4 @@ return item.sql; | ||
Connection = (function(_super) { | ||
__extends(Connection, _super); | ||
Connection = (function(superClass) { | ||
extend(Connection, superClass); | ||
@@ -160,16 +160,16 @@ Connection.prototype.connected = false; | ||
function Connection(_at_config, callback) { | ||
var err, _base, _base1, _base2, _base3, _ref1; | ||
this.config = _at_config; | ||
if ((_base = this.config).driver == null) { | ||
_base.driver = 'tedious'; | ||
function Connection(config1, callback) { | ||
var base, base1, base2, base3, err, ref1; | ||
this.config = config1; | ||
if ((base = this.config).driver == null) { | ||
base.driver = 'tedious'; | ||
} | ||
if ((_base1 = this.config).port == null) { | ||
_base1.port = 1433; | ||
if ((base1 = this.config).port == null) { | ||
base1.port = 1433; | ||
} | ||
if ((_base2 = this.config).options == null) { | ||
_base2.options = {}; | ||
if ((base2 = this.config).options == null) { | ||
base2.options = {}; | ||
} | ||
if ((_base3 = this.config).stream == null) { | ||
_base3.stream = false; | ||
if ((base3 = this.config).stream == null) { | ||
base3.stream = false; | ||
} | ||
@@ -180,3 +180,3 @@ if (/^(.*)\\(.*)$/.exec(this.config.server)) { | ||
} | ||
if (_ref1 = this.config.driver, __indexOf.call(DRIVERS, _ref1) >= 0) { | ||
if (ref1 = this.config.driver, indexOf.call(DRIVERS, ref1) >= 0) { | ||
this.driver = this.initializeDriver(require("./" + this.config.driver)); | ||
@@ -205,4 +205,4 @@ if (module.exports.fix) { | ||
Connection.prototype._debug = function(msg) { | ||
var _ref1; | ||
return (_ref1 = this._debugStream) != null ? _ref1.write((String(msg).replace(/\x1B\[[0-9;]*m/g, '')) + "\n") : void 0; | ||
var ref1; | ||
return (ref1 = this._debugStream) != null ? ref1.write((String(msg).replace(/\x1B\[[0-9;]*m/g, '')) + "\n") : void 0; | ||
}; | ||
@@ -393,4 +393,4 @@ | ||
PreparedStatement = (function(_super) { | ||
__extends(PreparedStatement, _super); | ||
PreparedStatement = (function(superClass) { | ||
extend(PreparedStatement, superClass); | ||
@@ -563,10 +563,10 @@ PreparedStatement.prototype._pooledConnection = null; | ||
req.input('params', TYPES.NVarChar, ((function() { | ||
var _ref1, _results; | ||
_ref1 = this.parameters; | ||
_results = []; | ||
for (name in _ref1) { | ||
param = _ref1[name]; | ||
_results.push("@" + name + " " + (declare(param.type, param)) + (param.io === 2 ? " output" : "")); | ||
var ref1, results; | ||
ref1 = this.parameters; | ||
results = []; | ||
for (name in ref1) { | ||
param = ref1[name]; | ||
results.push("@" + name + " " + (declare(param.type, param)) + (param.io === 2 ? " output" : "")); | ||
} | ||
return _results; | ||
return results; | ||
}).call(_this)).join(',')); | ||
@@ -674,3 +674,3 @@ req.input('stmt', TYPES.NVarChar, _this.statement); | ||
PreparedStatement.prototype._execute = function(values, callback) { | ||
var name, param, req, _ref1; | ||
var name, param, ref1, req; | ||
req = new Request(this); | ||
@@ -681,5 +681,5 @@ if (this.stream != null) { | ||
req.input('handle', TYPES.Int, this._handle); | ||
_ref1 = this.parameters; | ||
for (name in _ref1) { | ||
param = _ref1[name]; | ||
ref1 = this.parameters; | ||
for (name in ref1) { | ||
param = ref1[name]; | ||
req.parameters[name] = { | ||
@@ -776,4 +776,4 @@ name: name, | ||
Transaction = (function(_super) { | ||
__extends(Transaction, _super); | ||
Transaction = (function(superClass) { | ||
extend(Transaction, superClass); | ||
@@ -802,3 +802,3 @@ Transaction.prototype._pooledConnection = null; | ||
function Transaction(connection) { | ||
this._abort = __bind(this._abort, this); | ||
this._abort = bind(this._abort, this); | ||
this.connection = connection != null ? connection : global_connection; | ||
@@ -930,8 +930,8 @@ this._queue = []; | ||
return function() { | ||
var _results; | ||
_results = []; | ||
var results; | ||
results = []; | ||
while (toAbort.length) { | ||
_results.push(toAbort.shift()(new TransactionError("Transaction aborted.", "EABORT"))); | ||
results.push(toAbort.shift()(new TransactionError("Transaction aborted.", "EABORT"))); | ||
} | ||
return _results; | ||
return results; | ||
}; | ||
@@ -1064,4 +1064,4 @@ })(this)); | ||
Request = (function(_super) { | ||
__extends(Request, _super); | ||
Request = (function(superClass) { | ||
extend(Request, superClass); | ||
@@ -1266,5 +1266,5 @@ Request.prototype.connection = null; | ||
Request.prototype.batch = function(batch, callback) { | ||
var _ref1; | ||
var ref1; | ||
if (this.stream == null) { | ||
this.stream = (_ref1 = this.connection) != null ? _ref1.config.stream : void 0; | ||
this.stream = (ref1 = this.connection) != null ? ref1.config.stream : void 0; | ||
} | ||
@@ -1343,5 +1343,5 @@ if (this.stream || (callback != null)) { | ||
Request.prototype.bulk = function(table, callback) { | ||
var _ref1; | ||
var ref1; | ||
if (this.stream == null) { | ||
this.stream = (_ref1 = this.connection) != null ? _ref1.config.stream : void 0; | ||
this.stream = (ref1 = this.connection) != null ? ref1.config.stream : void 0; | ||
} | ||
@@ -1464,5 +1464,5 @@ if (this.stream || (callback != null)) { | ||
Request.prototype.query = function(command, callback) { | ||
var _ref1; | ||
var ref1; | ||
if (this.stream == null) { | ||
this.stream = (_ref1 = this.connection) != null ? _ref1.config.stream : void 0; | ||
this.stream = (ref1 = this.connection) != null ? ref1.config.stream : void 0; | ||
} | ||
@@ -1560,5 +1560,5 @@ if (this.stream || (callback != null)) { | ||
Request.prototype.execute = function(command, callback) { | ||
var _ref1; | ||
var ref1; | ||
if (this.stream == null) { | ||
this.stream = (_ref1 = this.connection) != null ? _ref1.config.stream : void 0; | ||
this.stream = (ref1 = this.connection) != null ? ref1.config.stream : void 0; | ||
} | ||
@@ -1640,4 +1640,4 @@ if (this.stream || (callback != null)) { | ||
ConnectionError = (function(_super) { | ||
__extends(ConnectionError, _super); | ||
ConnectionError = (function(superClass) { | ||
extend(ConnectionError, superClass); | ||
@@ -1673,4 +1673,4 @@ function ConnectionError(message, code) { | ||
TransactionError = (function(_super) { | ||
__extends(TransactionError, _super); | ||
TransactionError = (function(superClass) { | ||
extend(TransactionError, superClass); | ||
@@ -1706,16 +1706,16 @@ function TransactionError(message, code) { | ||
RequestError = (function(_super) { | ||
__extends(RequestError, _super); | ||
RequestError = (function(superClass) { | ||
extend(RequestError, superClass); | ||
function RequestError(message, code) { | ||
var err, _ref1, _ref10, _ref11, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9; | ||
var err, ref1, ref10, ref11, ref2, ref3, ref4, ref5, ref6, ref7, ref8, ref9; | ||
if (!(this instanceof RequestError)) { | ||
if (message instanceof Error) { | ||
err = new RequestError(message.message, (_ref1 = message.code) != null ? _ref1 : code); | ||
err.number = (_ref2 = (_ref3 = message.info) != null ? _ref3.number : void 0) != null ? _ref2 : message.code; | ||
err.lineNumber = (_ref4 = message.info) != null ? _ref4.lineNumber : void 0; | ||
err.state = (_ref5 = (_ref6 = message.info) != null ? _ref6.state : void 0) != null ? _ref5 : message.sqlstate; | ||
err["class"] = (_ref7 = (_ref8 = message.info) != null ? _ref8["class"] : void 0) != null ? _ref7 : (_ref9 = message.info) != null ? _ref9.severity : void 0; | ||
err.serverName = (_ref10 = message.info) != null ? _ref10.serverName : void 0; | ||
err.procName = (_ref11 = message.info) != null ? _ref11.procName : void 0; | ||
err = new RequestError(message.message, (ref1 = message.code) != null ? ref1 : code); | ||
err.number = (ref2 = (ref3 = message.info) != null ? ref3.number : void 0) != null ? ref2 : message.code; | ||
err.lineNumber = (ref4 = message.info) != null ? ref4.lineNumber : void 0; | ||
err.state = (ref5 = (ref6 = message.info) != null ? ref6.state : void 0) != null ? ref5 : message.sqlstate; | ||
err["class"] = (ref7 = (ref8 = message.info) != null ? ref8["class"] : void 0) != null ? ref7 : (ref9 = message.info) != null ? ref9.severity : void 0; | ||
err.serverName = (ref10 = message.info) != null ? ref10.serverName : void 0; | ||
err.procName = (ref11 = message.info) != null ? ref11.procName : void 0; | ||
Object.defineProperty(err, 'originalError', { | ||
@@ -1745,4 +1745,4 @@ value: message | ||
PreparedStatementError = (function(_super) { | ||
__extends(PreparedStatementError, _super); | ||
PreparedStatementError = (function(superClass) { | ||
extend(PreparedStatementError, superClass); | ||
@@ -1835,3 +1835,3 @@ function PreparedStatementError(message, code) { | ||
module.exports.Promise = (_ref1 = global.Promise) != null ? _ref1 : require('promise'); | ||
module.exports.Promise = (ref1 = global.Promise) != null ? ref1 : require('promise'); | ||
@@ -1838,0 +1838,0 @@ for (key in TYPES) { |
@@ -1,6 +0,6 @@ | ||
// Generated by CoffeeScript 1.9.0 | ||
// Generated by CoffeeScript 1.9.2 | ||
(function() { | ||
var CONNECTION_STRING_NAMED_INSTANCE, CONNECTION_STRING_PORT, DECLARATIONS, EMPTY_BUFFER, ISOLATION_LEVEL, Pool, TYPES, UDT, castParameter, createColumns, declare, isolationLevelDeclaration, msnodesql, util, valueCorrection, _ref, | ||
__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; }, | ||
__hasProp = {}.hasOwnProperty; | ||
var CONNECTION_STRING_NAMED_INSTANCE, CONNECTION_STRING_PORT, DECLARATIONS, EMPTY_BUFFER, ISOLATION_LEVEL, Pool, TYPES, UDT, castParameter, createColumns, declare, isolationLevelDeclaration, msnodesql, ref, util, valueCorrection, | ||
extend = 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; }, | ||
hasProp = {}.hasOwnProperty; | ||
@@ -13,3 +13,3 @@ Pool = require('generic-pool').Pool; | ||
_ref = require('./datatypes'), TYPES = _ref.TYPES, declare = _ref.declare; | ||
ref = require('./datatypes'), TYPES = ref.TYPES, declare = ref.declare; | ||
@@ -105,5 +105,5 @@ UDT = require('./udt').PARSERS; | ||
createColumns = function(metadata) { | ||
var column, index, out, _i, _len; | ||
var column, i, index, len, out; | ||
out = {}; | ||
for (index = _i = 0, _len = metadata.length; _i < _len; index = ++_i) { | ||
for (index = i = 0, len = metadata.length; i < len; index = ++i) { | ||
column = metadata[index]; | ||
@@ -177,4 +177,4 @@ out[column.name] = { | ||
var MsnodesqlConnection, MsnodesqlRequest, MsnodesqlTransaction; | ||
MsnodesqlConnection = (function(_super) { | ||
__extends(MsnodesqlConnection, _super); | ||
MsnodesqlConnection = (function(superClass) { | ||
extend(MsnodesqlConnection, superClass); | ||
@@ -188,3 +188,3 @@ function MsnodesqlConnection() { | ||
MsnodesqlConnection.prototype.connect = function(config, callback) { | ||
var cfg, cfg_pool, defaultConnectionString, key, value, _ref1, _ref2; | ||
var cfg, cfg_pool, defaultConnectionString, key, ref1, ref2, value; | ||
defaultConnectionString = CONNECTION_STRING_PORT; | ||
@@ -195,6 +195,6 @@ if (config.options.instanceName != null) { | ||
cfg = { | ||
connectionString: (_ref1 = config.connectionString) != null ? _ref1 : defaultConnectionString | ||
connectionString: (ref1 = config.connectionString) != null ? ref1 : defaultConnectionString | ||
}; | ||
cfg.connectionString = cfg.connectionString.replace(new RegExp('#{([^}]*)}', 'g'), function(p) { | ||
var key, _ref2; | ||
var key, ref2; | ||
key = p.substr(2, p.length - 3); | ||
@@ -210,3 +210,3 @@ if (key === 'instance') { | ||
} else { | ||
return (_ref2 = config[key]) != null ? _ref2 : ''; | ||
return (ref2 = config[key]) != null ? ref2 : ''; | ||
} | ||
@@ -240,5 +240,5 @@ }); | ||
if (config.pool) { | ||
_ref2 = config.pool; | ||
for (key in _ref2) { | ||
value = _ref2[key]; | ||
ref2 = config.pool; | ||
for (key in ref2) { | ||
value = ref2[key]; | ||
cfg_pool[key] = value; | ||
@@ -255,5 +255,5 @@ } | ||
_this.pool.drain(function() { | ||
var _ref3; | ||
if ((_ref3 = _this.pool) != null) { | ||
_ref3.destroyAllNow(); | ||
var ref3; | ||
if ((ref3 = _this.pool) != null) { | ||
ref3.destroyAllNow(); | ||
} | ||
@@ -276,5 +276,5 @@ return _this.pool = null; | ||
return function() { | ||
var _ref1; | ||
if ((_ref1 = _this.pool) != null) { | ||
_ref1.destroyAllNow(); | ||
var ref1; | ||
if ((ref1 = _this.pool) != null) { | ||
ref1.destroyAllNow(); | ||
} | ||
@@ -290,4 +290,4 @@ _this.pool = null; | ||
})(Connection); | ||
MsnodesqlTransaction = (function(_super) { | ||
__extends(MsnodesqlTransaction, _super); | ||
MsnodesqlTransaction = (function(superClass) { | ||
extend(MsnodesqlTransaction, superClass); | ||
@@ -333,4 +333,4 @@ function MsnodesqlTransaction() { | ||
})(Transaction); | ||
MsnodesqlRequest = (function(_super) { | ||
__extends(MsnodesqlRequest, _super); | ||
MsnodesqlRequest = (function(superClass) { | ||
extend(MsnodesqlRequest, superClass); | ||
@@ -376,34 +376,34 @@ function MsnodesqlRequest() { | ||
input = (function() { | ||
var _ref1, _results; | ||
_ref1 = this.parameters; | ||
_results = []; | ||
for (name in _ref1) { | ||
param = _ref1[name]; | ||
_results.push("@" + param.name + " " + (declare(param.type, param))); | ||
var ref1, results; | ||
ref1 = this.parameters; | ||
results = []; | ||
for (name in ref1) { | ||
param = ref1[name]; | ||
results.push("@" + param.name + " " + (declare(param.type, param))); | ||
} | ||
return _results; | ||
return results; | ||
}).call(this); | ||
sets = (function() { | ||
var _ref1, _results; | ||
_ref1 = this.parameters; | ||
_results = []; | ||
for (name in _ref1) { | ||
param = _ref1[name]; | ||
var ref1, results; | ||
ref1 = this.parameters; | ||
results = []; | ||
for (name in ref1) { | ||
param = ref1[name]; | ||
if (param.io === 1) { | ||
_results.push("set @" + param.name + "=?"); | ||
results.push("set @" + param.name + "=?"); | ||
} | ||
} | ||
return _results; | ||
return results; | ||
}).call(this); | ||
output = (function() { | ||
var _ref1, _results; | ||
_ref1 = this.parameters; | ||
_results = []; | ||
for (name in _ref1) { | ||
param = _ref1[name]; | ||
var ref1, results; | ||
ref1 = this.parameters; | ||
results = []; | ||
for (name in ref1) { | ||
param = ref1[name]; | ||
if (param.io === 2) { | ||
_results.push("@" + param.name + " as '" + param.name + "'"); | ||
results.push("@" + param.name + " as '" + param.name + "'"); | ||
} | ||
} | ||
return _results; | ||
return results; | ||
}).call(this); | ||
@@ -423,12 +423,12 @@ if (input.length) { | ||
req = connection.queryRaw(command, (function() { | ||
var _ref1, _results; | ||
_ref1 = this.parameters; | ||
_results = []; | ||
for (name in _ref1) { | ||
param = _ref1[name]; | ||
var ref1, results; | ||
ref1 = this.parameters; | ||
results = []; | ||
for (name in ref1) { | ||
param = ref1[name]; | ||
if (param.io === 1) { | ||
_results.push(castParameter(param.value, param.type)); | ||
results.push(castParameter(param.value, param.type)); | ||
} | ||
} | ||
return _results; | ||
return results; | ||
}).call(_this)); | ||
@@ -510,6 +510,7 @@ if (_this.verbose && !_this.nested) { | ||
} | ||
_this._release(connection); | ||
return typeof callback === "function" ? callback(e) : void 0; | ||
}); | ||
return req.once('done', function() { | ||
var elapsed, last, _ref1, _ref2; | ||
var elapsed, last, ref1, ref2; | ||
if (!_this.nested) { | ||
@@ -528,6 +529,6 @@ if (row) { | ||
if (handleOutput) { | ||
last = (_ref1 = recordsets.pop()) != null ? _ref1[0] : void 0; | ||
_ref2 = _this.parameters; | ||
for (name in _ref2) { | ||
param = _ref2[name]; | ||
last = (ref1 = recordsets.pop()) != null ? ref1[0] : void 0; | ||
ref2 = _this.parameters; | ||
for (name in ref2) { | ||
param = ref2[name]; | ||
if (!(param.io === 2)) { | ||
@@ -566,3 +567,3 @@ continue; | ||
MsnodesqlRequest.prototype.execute = function(procedure, callback) { | ||
var cmd, name, param, spp, started, _ref1; | ||
var cmd, name, param, ref1, spp, started; | ||
if (this.verbose) { | ||
@@ -573,18 +574,18 @@ this._log("---------- sql execute --------\n proc: " + procedure); | ||
cmd = "declare " + (['@___return___ int'].concat((function() { | ||
var _ref1, _results; | ||
_ref1 = this.parameters; | ||
_results = []; | ||
for (name in _ref1) { | ||
param = _ref1[name]; | ||
var ref1, results; | ||
ref1 = this.parameters; | ||
results = []; | ||
for (name in ref1) { | ||
param = ref1[name]; | ||
if (param.io === 2) { | ||
_results.push("@" + param.name + " " + (declare(param.type, param))); | ||
results.push("@" + param.name + " " + (declare(param.type, param))); | ||
} | ||
} | ||
return _results; | ||
return results; | ||
}).call(this)).join(', ')) + ";"; | ||
cmd += "exec @___return___ = " + procedure + " "; | ||
spp = []; | ||
_ref1 = this.parameters; | ||
for (name in _ref1) { | ||
param = _ref1[name]; | ||
ref1 = this.parameters; | ||
for (name in ref1) { | ||
param = ref1[name]; | ||
if (this.verbose) { | ||
@@ -601,12 +602,12 @@ this._log(" " + (param.io === 1 ? " input" : "output") + ": @" + param.name + ", " + param.type.declaration + ", " + param.value); | ||
cmd += "select " + (['@___return___ as \'___return___\''].concat((function() { | ||
var _ref2, _results; | ||
_ref2 = this.parameters; | ||
_results = []; | ||
for (name in _ref2) { | ||
param = _ref2[name]; | ||
var ref2, results; | ||
ref2 = this.parameters; | ||
results = []; | ||
for (name in ref2) { | ||
param = ref2[name]; | ||
if (param.io === 2) { | ||
_results.push("@" + param.name + " as '" + param.name + "'"); | ||
results.push("@" + param.name + " as '" + param.name + "'"); | ||
} | ||
} | ||
return _results; | ||
return results; | ||
}).call(this)).join(', ')) + ";"; | ||
@@ -619,3 +620,3 @@ if (this.verbose) { | ||
return function(err, recordsets) { | ||
var elapsed, last, returnValue, _ref2, _ref3; | ||
var elapsed, last, ref2, ref3, returnValue; | ||
_this.nested = false; | ||
@@ -634,9 +635,9 @@ if (err) { | ||
} else { | ||
last = (_ref2 = recordsets.pop()) != null ? _ref2[0] : void 0; | ||
last = (ref2 = recordsets.pop()) != null ? ref2[0] : void 0; | ||
} | ||
if (last && (last.___return___ != null)) { | ||
returnValue = last.___return___; | ||
_ref3 = _this.parameters; | ||
for (name in _ref3) { | ||
param = _ref3[name]; | ||
ref3 = _this.parameters; | ||
for (name in ref3) { | ||
param = ref3[name]; | ||
if (!(param.io === 2)) { | ||
@@ -643,0 +644,0 @@ continue; |
@@ -1,7 +0,7 @@ | ||
// Generated by CoffeeScript 1.9.0 | ||
// Generated by CoffeeScript 1.9.2 | ||
(function() { | ||
var MAX, TYPES, Table, declare, _ref, | ||
__slice = [].slice; | ||
var MAX, TYPES, Table, declare, ref, | ||
slice = [].slice; | ||
_ref = require('./datatypes'), TYPES = _ref.TYPES, declare = _ref.declare; | ||
ref = require('./datatypes'), TYPES = ref.TYPES, declare = ref.declare; | ||
@@ -12,3 +12,3 @@ MAX = 65535; | ||
function Table(name) { | ||
var path, _ref1; | ||
var path, ref1; | ||
if (name) { | ||
@@ -18,3 +18,3 @@ path = name.match(/^(\[?([^\]]*)\]?\.)?(\[?([^\]]*)\]?\.)?\[?([^\]]*)\]?$/); | ||
this.schema = path[4] != null ? path[4] : path[2] ? path[2] : null; | ||
this.database = path[4] != null ? (_ref1 = path[2]) != null ? _ref1 : null : null; | ||
this.database = path[4] != null ? (ref1 = path[2]) != null ? ref1 : null : null; | ||
this.path = "" + (this.database ? "[" + this.database + "]." : "") + (this.schema ? "[" + this.schema + "]." : "") + "[" + this.name + "]"; | ||
@@ -44,3 +44,3 @@ this.temporary = this.name.charAt(0) === '#'; | ||
var values; | ||
values = 1 <= arguments.length ? __slice.call(arguments, 0) : []; | ||
values = 1 <= arguments.length ? slice.call(arguments, 0) : []; | ||
return this.push(values); | ||
@@ -57,6 +57,6 @@ } | ||
Table.prototype._makeBulk = function() { | ||
var col, _i, _len, _ref1; | ||
_ref1 = this.columns; | ||
for (_i = 0, _len = _ref1.length; _i < _len; _i++) { | ||
col = _ref1[_i]; | ||
var col, i, len, ref1; | ||
ref1 = this.columns; | ||
for (i = 0, len = ref1.length; i < len; i++) { | ||
col = ref1[i]; | ||
switch (col.type) { | ||
@@ -78,10 +78,10 @@ case TYPES.Xml: | ||
return "create table " + this.path + " (" + (((function() { | ||
var _i, _len, _ref1, _results; | ||
_ref1 = this.columns; | ||
_results = []; | ||
for (_i = 0, _len = _ref1.length; _i < _len; _i++) { | ||
col = _ref1[_i]; | ||
_results.push("[" + col.name + "] " + (declare(col.type, col)) + (col.nullable === true ? " null" : col.nullable === false ? " not null" : "")); | ||
var i, len, ref1, results; | ||
ref1 = this.columns; | ||
results = []; | ||
for (i = 0, len = ref1.length; i < len; i++) { | ||
col = ref1[i]; | ||
results.push("[" + col.name + "] " + (declare(col.type, col)) + (col.nullable === true ? " null" : col.nullable === false ? " not null" : "")); | ||
} | ||
return _results; | ||
return results; | ||
}).call(this)).join(', ')) + ")"; | ||
@@ -91,7 +91,7 @@ }; | ||
Table.fromRecordset = function(recordset) { | ||
var col, name, row, t, _i, _len, _ref1, _ref2; | ||
var col, i, len, name, ref1, ref2, row, t; | ||
t = new this; | ||
_ref1 = recordset.columns; | ||
for (name in _ref1) { | ||
col = _ref1[name]; | ||
ref1 = recordset.columns; | ||
for (name in ref1) { | ||
col = ref1[name]; | ||
t.columns.add(name, { | ||
@@ -106,13 +106,13 @@ type: col.type, | ||
} | ||
for (_i = 0, _len = recordset.length; _i < _len; _i++) { | ||
row = recordset[_i]; | ||
(_ref2 = t.rows).add.apply(_ref2, (function() { | ||
var _j, _len1, _ref2, _results; | ||
_ref2 = t.columns; | ||
_results = []; | ||
for (_j = 0, _len1 = _ref2.length; _j < _len1; _j++) { | ||
col = _ref2[_j]; | ||
_results.push(row[col.name]); | ||
for (i = 0, len = recordset.length; i < len; i++) { | ||
row = recordset[i]; | ||
(ref2 = t.rows).add.apply(ref2, (function() { | ||
var j, len1, ref2, results; | ||
ref2 = t.columns; | ||
results = []; | ||
for (j = 0, len1 = ref2.length; j < len1; j++) { | ||
col = ref2[j]; | ||
results.push(row[col.name]); | ||
} | ||
return _results; | ||
return results; | ||
})()); | ||
@@ -119,0 +119,0 @@ } |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.9.0 | ||
// Generated by CoffeeScript 1.9.2 | ||
(function() { | ||
@@ -3,0 +3,0 @@ var ex; |
158
lib/tds.js
@@ -1,6 +0,6 @@ | ||
// Generated by CoffeeScript 1.9.0 | ||
// Generated by CoffeeScript 1.9.2 | ||
(function() { | ||
var FIXED, ISOLATION_LEVEL, Pool, TYPES, castParameter, createColumns, createParameterHeader, declare, formatHex, isolationLevelDeclaration, parseGuid, tds, util, _ref, | ||
__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; }, | ||
__hasProp = {}.hasOwnProperty; | ||
var FIXED, ISOLATION_LEVEL, Pool, TYPES, castParameter, createColumns, createParameterHeader, declare, formatHex, isolationLevelDeclaration, parseGuid, ref, tds, util, | ||
extend = 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; }, | ||
hasProp = {}.hasOwnProperty; | ||
@@ -15,3 +15,3 @@ Pool = require('generic-pool').Pool; | ||
_ref = require('./datatypes'), TYPES = _ref.TYPES, declare = _ref.declare; | ||
ref = require('./datatypes'), TYPES = ref.TYPES, declare = ref.declare; | ||
@@ -94,3 +94,3 @@ ISOLATION_LEVEL = require('./isolationlevel'); | ||
createParameterHeader = function(param) { | ||
var header, _ref1, _ref2, _ref3; | ||
var header, ref1, ref2, ref3; | ||
header = { | ||
@@ -108,3 +108,3 @@ type: param.type.declaration | ||
case TYPES.Binary: | ||
header.size = (_ref1 = (_ref2 = param.length) != null ? _ref2 : (_ref3 = param.value) != null ? _ref3.length : void 0) != null ? _ref1 : 1; | ||
header.size = (ref1 = (ref2 = param.length) != null ? ref2 : (ref3 = param.value) != null ? ref3.length : void 0) != null ? ref1 : 1; | ||
} | ||
@@ -120,5 +120,5 @@ return header; | ||
createColumns = function(metadata) { | ||
var column, index, out, _i, _len; | ||
var column, i, index, len, out; | ||
out = {}; | ||
for (index = _i = 0, _len = metadata.length; _i < _len; index = ++_i) { | ||
for (index = i = 0, len = metadata.length; i < len; index = ++i) { | ||
column = metadata[index]; | ||
@@ -193,4 +193,4 @@ out[column.name] = { | ||
var TDSConnection, TDSRequest, TDSTransaction; | ||
TDSConnection = (function(_super) { | ||
__extends(TDSConnection, _super); | ||
TDSConnection = (function(superClass) { | ||
extend(TDSConnection, superClass); | ||
@@ -204,3 +204,3 @@ function TDSConnection() { | ||
TDSConnection.prototype.connect = function(config, callback) { | ||
var cfg, cfg_pool, key, value, _ref1; | ||
var cfg, cfg_pool, key, ref1, value; | ||
cfg = { | ||
@@ -220,3 +220,3 @@ userName: config.user, | ||
return function(callback) { | ||
var c, timeouted, tmr, _ref1; | ||
var c, ref1, timeouted, tmr; | ||
c = new tds.Connection(cfg); | ||
@@ -228,3 +228,3 @@ timeouted = false; | ||
return callback(new ConnectionError("Connection timeout.", 'ETIMEOUT'), null); | ||
}, (_ref1 = config.timeout) != null ? _ref1 : 15000); | ||
}, (ref1 = config.timeout) != null ? ref1 : 15000); | ||
return c.connect(function(err) { | ||
@@ -253,5 +253,5 @@ clearTimeout(tmr); | ||
if (config.pool) { | ||
_ref1 = config.pool; | ||
for (key in _ref1) { | ||
value = _ref1[key]; | ||
ref1 = config.pool; | ||
for (key in ref1) { | ||
value = ref1[key]; | ||
cfg_pool[key] = value; | ||
@@ -268,5 +268,5 @@ } | ||
_this.pool.drain(function() { | ||
var _ref2; | ||
if ((_ref2 = _this.pool) != null) { | ||
_ref2.destroyAllNow(); | ||
var ref2; | ||
if ((ref2 = _this.pool) != null) { | ||
ref2.destroyAllNow(); | ||
} | ||
@@ -289,5 +289,5 @@ return _this.pool = null; | ||
return function() { | ||
var _ref1; | ||
if ((_ref1 = _this.pool) != null) { | ||
_ref1.destroyAllNow(); | ||
var ref1; | ||
if ((ref1 = _this.pool) != null) { | ||
ref1.destroyAllNow(); | ||
} | ||
@@ -303,4 +303,4 @@ _this.pool = null; | ||
})(Connection); | ||
TDSTransaction = (function(_super) { | ||
__extends(TDSTransaction, _super); | ||
TDSTransaction = (function(superClass) { | ||
extend(TDSTransaction, superClass); | ||
@@ -357,4 +357,4 @@ function TDSTransaction() { | ||
})(Transaction); | ||
TDSRequest = (function(_super) { | ||
__extends(TDSRequest, _super); | ||
TDSRequest = (function(superClass) { | ||
extend(TDSRequest, superClass); | ||
@@ -376,3 +376,3 @@ function TDSRequest() { | ||
TDSRequest.prototype.query = function(command, callback) { | ||
var errors, handleOutput, input, lastrow, name, output, param, paramHeaders, paramValues, recordset, recordsets, started, _ref1; | ||
var errors, handleOutput, input, lastrow, name, output, param, paramHeaders, paramValues, recordset, recordsets, ref1, started; | ||
if (this.verbose && !this.nested) { | ||
@@ -401,5 +401,5 @@ this._log("---------- sql query ----------\n query: " + command); | ||
paramValues = {}; | ||
_ref1 = this.parameters; | ||
for (name in _ref1) { | ||
param = _ref1[name]; | ||
ref1 = this.parameters; | ||
for (name in ref1) { | ||
param = ref1[name]; | ||
if (!(param.io === 1)) { | ||
@@ -413,24 +413,24 @@ continue; | ||
input = (function() { | ||
var _ref2, _results; | ||
_ref2 = this.parameters; | ||
_results = []; | ||
for (name in _ref2) { | ||
param = _ref2[name]; | ||
var ref2, results; | ||
ref2 = this.parameters; | ||
results = []; | ||
for (name in ref2) { | ||
param = ref2[name]; | ||
if (param.io === 2) { | ||
_results.push("@" + param.name + " " + (declare(param.type, param))); | ||
results.push("@" + param.name + " " + (declare(param.type, param))); | ||
} | ||
} | ||
return _results; | ||
return results; | ||
}).call(this); | ||
output = (function() { | ||
var _ref2, _results; | ||
_ref2 = this.parameters; | ||
_results = []; | ||
for (name in _ref2) { | ||
param = _ref2[name]; | ||
var ref2, results; | ||
ref2 = this.parameters; | ||
results = []; | ||
for (name in ref2) { | ||
param = ref2[name]; | ||
if (param.io === 2) { | ||
_results.push("@" + param.name + " as '" + param.name + "'"); | ||
results.push("@" + param.name + " as '" + param.name + "'"); | ||
} | ||
} | ||
return _results; | ||
return results; | ||
}).call(this); | ||
@@ -464,7 +464,7 @@ if (input.length) { | ||
req.on('row', function(tdsrow) { | ||
var col, exi, row, value, _i, _len, _ref2; | ||
var col, exi, i, len, ref2, row, value; | ||
row = {}; | ||
_ref2 = tdsrow.metadata.columns; | ||
for (_i = 0, _len = _ref2.length; _i < _len; _i++) { | ||
col = _ref2[_i]; | ||
ref2 = tdsrow.metadata.columns; | ||
for (i = 0, len = ref2.length; i < len; i++) { | ||
col = ref2[i]; | ||
value = tdsrow.getValue(col.name); | ||
@@ -517,3 +517,3 @@ if (value != null) { | ||
req.on('done', function(res) { | ||
var e, elapsed, error, last, _i, _len, _ref2, _ref3; | ||
var e, elapsed, error, i, last, len, ref2, ref3; | ||
if (_this.canceled) { | ||
@@ -529,6 +529,6 @@ e = new RequestError("Canceled.", 'ECANCEL'); | ||
if (handleOutput) { | ||
last = (_ref2 = recordsets.pop()) != null ? _ref2[0] : void 0; | ||
_ref3 = _this.parameters; | ||
for (name in _ref3) { | ||
param = _ref3[name]; | ||
last = (ref2 = recordsets.pop()) != null ? ref2[0] : void 0; | ||
ref3 = _this.parameters; | ||
for (name in ref3) { | ||
param = ref3[name]; | ||
if (!(param.io === 2)) { | ||
@@ -545,4 +545,4 @@ continue; | ||
if (errors.length) { | ||
for (_i = 0, _len = errors.length; _i < _len; _i++) { | ||
error = errors[_i]; | ||
for (i = 0, len = errors.length; i < len; i++) { | ||
error = errors[i]; | ||
_this._log(" error: " + error); | ||
@@ -588,3 +588,3 @@ } | ||
TDSRequest.prototype.execute = function(procedure, callback) { | ||
var cmd, name, param, spp, started, _ref1; | ||
var cmd, name, param, ref1, spp, started; | ||
if (this.verbose) { | ||
@@ -595,18 +595,18 @@ this._log("---------- sql execute --------\n proc: " + procedure); | ||
cmd = "declare " + (['@___return___ int'].concat((function() { | ||
var _ref1, _results; | ||
_ref1 = this.parameters; | ||
_results = []; | ||
for (name in _ref1) { | ||
param = _ref1[name]; | ||
var ref1, results; | ||
ref1 = this.parameters; | ||
results = []; | ||
for (name in ref1) { | ||
param = ref1[name]; | ||
if (param.io === 2) { | ||
_results.push("@" + param.name + " " + (declare(param.type, param))); | ||
results.push("@" + param.name + " " + (declare(param.type, param))); | ||
} | ||
} | ||
return _results; | ||
return results; | ||
}).call(this)).join(', ')) + ";"; | ||
cmd += "exec @___return___ = " + procedure + " "; | ||
spp = []; | ||
_ref1 = this.parameters; | ||
for (name in _ref1) { | ||
param = _ref1[name]; | ||
ref1 = this.parameters; | ||
for (name in ref1) { | ||
param = ref1[name]; | ||
if (this.verbose) { | ||
@@ -623,12 +623,12 @@ this._log(" " + (param.io === 1 ? " input" : "output") + ": @" + param.name + ", " + param.type.declaration + ", " + param.value); | ||
cmd += "select " + (['@___return___ as \'___return___\''].concat((function() { | ||
var _ref2, _results; | ||
_ref2 = this.parameters; | ||
_results = []; | ||
for (name in _ref2) { | ||
param = _ref2[name]; | ||
var ref2, results; | ||
ref2 = this.parameters; | ||
results = []; | ||
for (name in ref2) { | ||
param = ref2[name]; | ||
if (param.io === 2) { | ||
_results.push("@" + param.name + " as '" + param.name + "'"); | ||
results.push("@" + param.name + " as '" + param.name + "'"); | ||
} | ||
} | ||
return _results; | ||
return results; | ||
}).call(this)).join(', ')) + ";"; | ||
@@ -641,3 +641,3 @@ if (this.verbose) { | ||
return function(err, recordsets) { | ||
var elapsed, last, returnValue, _ref2, _ref3; | ||
var elapsed, last, ref2, ref3, returnValue; | ||
_this.nested = false; | ||
@@ -656,9 +656,9 @@ if (err) { | ||
} else { | ||
last = (_ref2 = recordsets.pop()) != null ? _ref2[0] : void 0; | ||
last = (ref2 = recordsets.pop()) != null ? ref2[0] : void 0; | ||
} | ||
if (last && (last.___return___ != null)) { | ||
returnValue = last.___return___; | ||
_ref3 = _this.parameters; | ||
for (name in _ref3) { | ||
param = _ref3[name]; | ||
ref3 = _this.parameters; | ||
for (name in ref3) { | ||
param = ref3[name]; | ||
if (!(param.io === 2)) { | ||
@@ -665,0 +665,0 @@ continue; |
@@ -1,6 +0,6 @@ | ||
// Generated by CoffeeScript 1.9.0 | ||
// Generated by CoffeeScript 1.9.2 | ||
(function() { | ||
var DECLARATIONS, Pool, TYPES, Table, UDT, cast, createColumns, declare, getMssqlType, getTediousType, parameterCorrection, tds, util, valueCorrection, _ref, | ||
__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; }, | ||
__hasProp = {}.hasOwnProperty; | ||
var DECLARATIONS, Pool, TYPES, Table, UDT, cast, createColumns, declare, getMssqlType, getTediousType, parameterCorrection, ref, tds, util, valueCorrection, | ||
extend = 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; }, | ||
hasProp = {}.hasOwnProperty; | ||
@@ -13,3 +13,3 @@ Pool = require('generic-pool').Pool; | ||
_ref = require('./datatypes'), TYPES = _ref.TYPES, declare = _ref.declare, cast = _ref.cast; | ||
ref = require('./datatypes'), TYPES = ref.TYPES, declare = ref.declare, cast = ref.cast; | ||
@@ -201,5 +201,5 @@ DECLARATIONS = require('./datatypes').DECLARATIONS; | ||
createColumns = function(metadata) { | ||
var column, index, out, _i, _len; | ||
var column, i, index, len, out; | ||
out = {}; | ||
for (index = _i = 0, _len = metadata.length; _i < _len; index = ++_i) { | ||
for (index = i = 0, len = metadata.length; i < len; index = ++i) { | ||
column = metadata[index]; | ||
@@ -253,3 +253,3 @@ out[column.colName] = { | ||
parameterCorrection = function(value) { | ||
var col, tvp, _i, _len, _ref1; | ||
var col, i, len, ref1, tvp; | ||
if (value instanceof Table) { | ||
@@ -262,5 +262,5 @@ tvp = { | ||
}; | ||
_ref1 = value.columns; | ||
for (_i = 0, _len = _ref1.length; _i < _len; _i++) { | ||
col = _ref1[_i]; | ||
ref1 = value.columns; | ||
for (i = 0, len = ref1.length; i < len; i++) { | ||
col = ref1[i]; | ||
tvp.columns.push({ | ||
@@ -287,4 +287,4 @@ name: col.name, | ||
var TediousConnection, TediousRequest, TediousTransaction; | ||
TediousConnection = (function(_super) { | ||
__extends(TediousConnection, _super); | ||
TediousConnection = (function(superClass) { | ||
extend(TediousConnection, superClass); | ||
@@ -298,3 +298,3 @@ function TediousConnection() { | ||
TediousConnection.prototype.connect = function(config, callback) { | ||
var cfg, cfg_pool, key, value, _base, _base1, _base2, _base3, _base4, _base5, _ref1, _ref2, _ref3, _ref4; | ||
var base, base1, base2, base3, base4, base5, cfg, cfg_pool, key, ref1, ref2, ref3, ref4, value; | ||
cfg = { | ||
@@ -307,16 +307,16 @@ userName: config.user, | ||
}; | ||
if ((_base = cfg.options).database == null) { | ||
_base.database = config.database; | ||
if ((base = cfg.options).database == null) { | ||
base.database = config.database; | ||
} | ||
if ((_base1 = cfg.options).port == null) { | ||
_base1.port = config.port; | ||
if ((base1 = cfg.options).port == null) { | ||
base1.port = config.port; | ||
} | ||
if ((_base2 = cfg.options).connectTimeout == null) { | ||
_base2.connectTimeout = (_ref1 = (_ref2 = config.connectionTimeout) != null ? _ref2 : config.timeout) != null ? _ref1 : 15000; | ||
if ((base2 = cfg.options).connectTimeout == null) { | ||
base2.connectTimeout = (ref1 = (ref2 = config.connectionTimeout) != null ? ref2 : config.timeout) != null ? ref1 : 15000; | ||
} | ||
if ((_base3 = cfg.options).requestTimeout == null) { | ||
_base3.requestTimeout = (_ref3 = config.requestTimeout) != null ? _ref3 : 15000; | ||
if ((base3 = cfg.options).requestTimeout == null) { | ||
base3.requestTimeout = (ref3 = config.requestTimeout) != null ? ref3 : 15000; | ||
} | ||
if ((_base4 = cfg.options).tdsVersion == null) { | ||
_base4.tdsVersion = '7_4'; | ||
if ((base4 = cfg.options).tdsVersion == null) { | ||
base4.tdsVersion = '7_4'; | ||
} | ||
@@ -326,4 +326,4 @@ cfg.options.rowCollectionOnDone = false; | ||
cfg.options.useColumnNames = false; | ||
if ((_base5 = cfg.options).appName == null) { | ||
_base5.appName = 'node-mssql'; | ||
if ((base5 = cfg.options).appName == null) { | ||
base5.appName = 'node-mssql'; | ||
} | ||
@@ -333,2 +333,11 @@ if (cfg.options.instanceName) { | ||
} | ||
if (isNaN(cfg.options.requestTimeout)) { | ||
cfg.options.requestTimeout = 15000; | ||
} | ||
if (cfg.options.requestTimeout === Infinity) { | ||
cfg.options.requestTimeout = 0; | ||
} | ||
if (cfg.options.requestTimeout < 0) { | ||
cfg.options.requestTimeout = 0; | ||
} | ||
if (config.debug) { | ||
@@ -383,5 +392,5 @@ cfg.options.debug = { | ||
if (config.pool) { | ||
_ref4 = config.pool; | ||
for (key in _ref4) { | ||
value = _ref4[key]; | ||
ref4 = config.pool; | ||
for (key in ref4) { | ||
value = ref4[key]; | ||
cfg_pool[key] = value; | ||
@@ -395,5 +404,5 @@ } | ||
_this.pool.drain(function() { | ||
var _ref5; | ||
if ((_ref5 = _this.pool) != null) { | ||
_ref5.destroyAllNow(); | ||
var ref5; | ||
if ((ref5 = _this.pool) != null) { | ||
ref5.destroyAllNow(); | ||
} | ||
@@ -416,5 +425,5 @@ return _this.pool = null; | ||
return function() { | ||
var _ref1; | ||
if ((_ref1 = _this.pool) != null) { | ||
_ref1.destroyAllNow(); | ||
var ref1; | ||
if ((ref1 = _this.pool) != null) { | ||
ref1.destroyAllNow(); | ||
} | ||
@@ -430,4 +439,4 @@ _this.pool = null; | ||
})(Connection); | ||
TediousTransaction = (function(_super) { | ||
__extends(TediousTransaction, _super); | ||
TediousTransaction = (function(superClass) { | ||
extend(TediousTransaction, superClass); | ||
@@ -500,4 +509,4 @@ function TediousTransaction() { | ||
})(Transaction); | ||
TediousRequest = (function(_super) { | ||
__extends(TediousRequest, _super); | ||
TediousRequest = (function(superClass) { | ||
extend(TediousRequest, superClass); | ||
@@ -552,3 +561,3 @@ function TediousRequest() { | ||
return function(err, connection) { | ||
var bulk, col, done, objectid, req, row, _i, _j, _len, _len1, _ref1, _ref2; | ||
var bulk, col, done, i, j, len, len1, objectid, ref1, ref2, req, row; | ||
if (!err) { | ||
@@ -573,4 +582,4 @@ if (_this.verbose) { | ||
done = function(err, rowCount) { | ||
var elapsed, error, _i, _len, _ref1; | ||
if (err && err.message !== ((_ref1 = errors[errors.length - 1]) != null ? _ref1.message : void 0)) { | ||
var elapsed, error, i, len, ref1; | ||
if (err && err.message !== ((ref1 = errors[errors.length - 1]) != null ? ref1.message : void 0)) { | ||
err = RequestError(err, 'EREQUEST'); | ||
@@ -584,4 +593,4 @@ if (_this.stream) { | ||
if (errors.length) { | ||
for (_i = 0, _len = errors.length; _i < _len; _i++) { | ||
error = errors[_i]; | ||
for (i = 0, len = errors.length; i < len; i++) { | ||
error = errors[i]; | ||
_this._log(" error: " + error); | ||
@@ -608,5 +617,5 @@ } | ||
bulk = connection.newBulkLoad(table.path, done); | ||
_ref1 = table.columns; | ||
for (_i = 0, _len = _ref1.length; _i < _len; _i++) { | ||
col = _ref1[_i]; | ||
ref1 = table.columns; | ||
for (i = 0, len = ref1.length; i < len; i++) { | ||
col = ref1[i]; | ||
bulk.addColumn(col.name, getTediousType(col.type), { | ||
@@ -619,5 +628,5 @@ nullable: col.nullable, | ||
} | ||
_ref2 = table.rows; | ||
for (_j = 0, _len1 = _ref2.length; _j < _len1; _j++) { | ||
row = _ref2[_j]; | ||
ref2 = table.rows; | ||
for (j = 0, len1 = ref2.length; j < len1; j++) { | ||
row = ref2[j]; | ||
bulk.addRow(row); | ||
@@ -677,3 +686,3 @@ } | ||
return function(err, connection) { | ||
var assigns, declarations, doneHandler, name, param, req, selects, value, _ref1, _ref2; | ||
var assigns, declarations, doneHandler, name, param, ref1, ref2, req, selects, value; | ||
if (!err) { | ||
@@ -698,4 +707,4 @@ if (_this.verbose) { | ||
req = new tds.Request(command, function(err) { | ||
var elapsed, error, name, value, _i, _len, _ref1; | ||
if (err && err.message !== ((_ref1 = errors[errors.length - 1]) != null ? _ref1.message : void 0)) { | ||
var elapsed, error, i, len, name, ref1, value; | ||
if (err && err.message !== ((ref1 = errors[errors.length - 1]) != null ? ref1.message : void 0)) { | ||
err = RequestError(err, 'EREQUEST'); | ||
@@ -728,4 +737,4 @@ if (_this.stream) { | ||
if (errors.length) { | ||
for (_i = 0, _len = errors.length; _i < _len; _i++) { | ||
error = errors[_i]; | ||
for (i = 0, len = errors.length; i < len; i++) { | ||
error = errors[i]; | ||
_this._log(" error: " + error); | ||
@@ -796,3 +805,3 @@ } | ||
req.on('row', function(columns) { | ||
var col, exi, row, _i, _len; | ||
var col, exi, i, len, row; | ||
if (!recordset) { | ||
@@ -802,4 +811,4 @@ recordset = []; | ||
row = {}; | ||
for (_i = 0, _len = columns.length; _i < _len; _i++) { | ||
col = columns[_i]; | ||
for (i = 0, len = columns.length; i < len; i++) { | ||
col = columns[i]; | ||
col.value = valueCorrection(col.value, col.metadata); | ||
@@ -837,5 +846,5 @@ exi = row[col.metadata.colName]; | ||
if (Object.keys(_this.parameters).length) { | ||
_ref1 = _this.parameters; | ||
for (name in _ref1) { | ||
param = _ref1[name]; | ||
ref1 = _this.parameters; | ||
for (name in ref1) { | ||
param = ref1[name]; | ||
value = getTediousType(param.type).validate(param.value); | ||
@@ -854,32 +863,32 @@ if (value instanceof TypeError) { | ||
declarations = (function() { | ||
var _ref2, _results; | ||
_ref2 = this.parameters; | ||
_results = []; | ||
for (name in _ref2) { | ||
param = _ref2[name]; | ||
_results.push("@" + name + " " + (declare(param.type, param))); | ||
var ref2, results; | ||
ref2 = this.parameters; | ||
results = []; | ||
for (name in ref2) { | ||
param = ref2[name]; | ||
results.push("@" + name + " " + (declare(param.type, param))); | ||
} | ||
return _results; | ||
return results; | ||
}).call(_this); | ||
assigns = (function() { | ||
var _ref2, _results; | ||
_ref2 = this.parameters; | ||
_results = []; | ||
for (name in _ref2) { | ||
param = _ref2[name]; | ||
_results.push("@" + name + " = " + (cast(param.value, param.type, param))); | ||
var ref2, results; | ||
ref2 = this.parameters; | ||
results = []; | ||
for (name in ref2) { | ||
param = ref2[name]; | ||
results.push("@" + name + " = " + (cast(param.value, param.type, param))); | ||
} | ||
return _results; | ||
return results; | ||
}).call(_this); | ||
selects = (function() { | ||
var _ref2, _results; | ||
_ref2 = this.parameters; | ||
_results = []; | ||
for (name in _ref2) { | ||
param = _ref2[name]; | ||
var ref2, results; | ||
ref2 = this.parameters; | ||
results = []; | ||
for (name in ref2) { | ||
param = ref2[name]; | ||
if (param.io === 2) { | ||
_results.push("@" + name + " as [" + name + "]"); | ||
results.push("@" + name + " as [" + name + "]"); | ||
} | ||
} | ||
return _results; | ||
return results; | ||
}).call(_this); | ||
@@ -890,5 +899,5 @@ batchHasOutput = selects.length > 0; | ||
} else { | ||
_ref2 = _this.parameters; | ||
for (name in _ref2) { | ||
param = _ref2[name]; | ||
ref2 = _this.parameters; | ||
for (name in ref2) { | ||
param = ref2[name]; | ||
if (_this.verbose) { | ||
@@ -957,3 +966,3 @@ if (param.value === tds.TYPES.Null) { | ||
return function(err, connection) { | ||
var name, param, req, _ref1; | ||
var name, param, ref1, req; | ||
if (!err) { | ||
@@ -978,4 +987,4 @@ if (_this.verbose) { | ||
req = new tds.Request(procedure, function(err) { | ||
var elapsed, error, _i, _len, _ref1; | ||
if (err && err.message !== ((_ref1 = errors[errors.length - 1]) != null ? _ref1.message : void 0)) { | ||
var elapsed, error, i, len, ref1; | ||
if (err && err.message !== ((ref1 = errors[errors.length - 1]) != null ? ref1.message : void 0)) { | ||
err = RequestError(err, 'EREQUEST'); | ||
@@ -989,4 +998,4 @@ if (_this.stream) { | ||
if (errors.length) { | ||
for (_i = 0, _len = errors.length; _i < _len; _i++) { | ||
error = errors[_i]; | ||
for (i = 0, len = errors.length; i < len; i++) { | ||
error = errors[i]; | ||
_this._log(" error: " + error); | ||
@@ -1021,3 +1030,3 @@ } | ||
req.on('row', function(columns) { | ||
var col, exi, row, _i, _len; | ||
var col, exi, i, len, row; | ||
if (!recordset) { | ||
@@ -1027,4 +1036,4 @@ recordset = []; | ||
row = {}; | ||
for (_i = 0, _len = columns.length; _i < _len; _i++) { | ||
col = columns[_i]; | ||
for (i = 0, len = columns.length; i < len; i++) { | ||
col = columns[i]; | ||
col.value = valueCorrection(col.value, col.metadata); | ||
@@ -1085,5 +1094,5 @@ exi = row[col.metadata.colName]; | ||
}); | ||
_ref1 = _this.parameters; | ||
for (name in _ref1) { | ||
param = _ref1[name]; | ||
ref1 = _this.parameters; | ||
for (name in ref1) { | ||
param = ref1[name]; | ||
if (_this.verbose) { | ||
@@ -1090,0 +1099,0 @@ if (param.value === tds.TYPES.Null) { |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.9.0 | ||
// Generated by CoffeeScript 1.9.2 | ||
(function() { | ||
@@ -133,3 +133,3 @@ var FIGURE, FIGURE_V2, Point, SEGMENT, SHAPE, SHAPE_V2, parseFigures, parseGeography, parseM, parsePoints, parseSegments, parseShapes, parseZ; | ||
parsePoints = function(buffer, count) { | ||
var i, point, points, _i; | ||
var i, j, point, points, ref; | ||
points = []; | ||
@@ -139,3 +139,3 @@ if (count < 1) { | ||
} | ||
for (i = _i = 1; 1 <= count ? _i <= count : _i >= count; i = 1 <= count ? ++_i : --_i) { | ||
for (i = j = 1, ref = count; 1 <= ref ? j <= ref : j >= ref; i = 1 <= ref ? ++j : --j) { | ||
points.push((point = new Point)); | ||
@@ -150,31 +150,31 @@ point.x = buffer.readDoubleLE(buffer.position); | ||
parseZ = function(buffer, points) { | ||
var point, _i, _len, _results; | ||
var j, len, point, results; | ||
if (points < 1) { | ||
return; | ||
} | ||
_results = []; | ||
for (_i = 0, _len = points.length; _i < _len; _i++) { | ||
point = points[_i]; | ||
results = []; | ||
for (j = 0, len = points.length; j < len; j++) { | ||
point = points[j]; | ||
point.z = buffer.readDoubleLE(buffer.position); | ||
_results.push(buffer.position += 8); | ||
results.push(buffer.position += 8); | ||
} | ||
return _results; | ||
return results; | ||
}; | ||
parseM = function(buffer, points) { | ||
var point, _i, _len, _results; | ||
var j, len, point, results; | ||
if (points < 1) { | ||
return; | ||
} | ||
_results = []; | ||
for (_i = 0, _len = points.length; _i < _len; _i++) { | ||
point = points[_i]; | ||
results = []; | ||
for (j = 0, len = points.length; j < len; j++) { | ||
point = points[j]; | ||
point.m = buffer.readDoubleLE(buffer.position); | ||
_results.push(buffer.position += 8); | ||
results.push(buffer.position += 8); | ||
} | ||
return _results; | ||
return results; | ||
}; | ||
parseFigures = function(buffer, count, properties) { | ||
var figures, i, _i; | ||
var figures, i, j, ref; | ||
figures = []; | ||
@@ -195,3 +195,3 @@ if (count < 1) { | ||
} else { | ||
for (i = _i = 1; 1 <= count ? _i <= count : _i >= count; i = 1 <= count ? ++_i : --_i) { | ||
for (i = j = 1, ref = count; 1 <= ref ? j <= ref : j >= ref; i = 1 <= ref ? ++j : --j) { | ||
figures.push({ | ||
@@ -208,3 +208,3 @@ attribute: buffer.readUInt8(buffer.position), | ||
parseShapes = function(buffer, count, properties) { | ||
var i, shapes, _i; | ||
var i, j, ref, shapes; | ||
shapes = []; | ||
@@ -227,3 +227,3 @@ if (count < 1) { | ||
} else { | ||
for (i = _i = 1; 1 <= count ? _i <= count : _i >= count; i = 1 <= count ? ++_i : --_i) { | ||
for (i = j = 1, ref = count; 1 <= ref ? j <= ref : j >= ref; i = 1 <= ref ? ++j : --j) { | ||
shapes.push({ | ||
@@ -241,3 +241,3 @@ parentOffset: buffer.readInt32LE(buffer.position), | ||
parseSegments = function(buffer, count) { | ||
var i, segments, _i; | ||
var i, j, ref, segments; | ||
segments = []; | ||
@@ -247,3 +247,3 @@ if (count < 1) { | ||
} | ||
for (i = _i = 1; 1 <= count ? _i <= count : _i >= count; i = 1 <= count ? ++_i : --_i) { | ||
for (i = j = 1, ref = count; 1 <= ref ? j <= ref : j >= ref; i = 1 <= ref ? ++j : --j) { | ||
segments.push({ | ||
@@ -250,0 +250,0 @@ type: buffer.readUInt8(buffer.position) |
@@ -20,3 +20,3 @@ { | ||
], | ||
"version": "2.1.2", | ||
"version": "2.1.3", | ||
"main": "index.js", | ||
@@ -35,4 +35,4 @@ "repository": { | ||
"tedious": "^1.11.0", | ||
"generic-pool": "^2.1.1", | ||
"promise": "^6.1.0" | ||
"generic-pool": "^2.2.0", | ||
"promise": "^7.0.1" | ||
}, | ||
@@ -39,0 +39,0 @@ "devDependencies": { |
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
315489
4770
+ Addedasap@2.0.6(transitive)
+ Addedpromise@7.3.1(transitive)
- Removedasap@1.0.0(transitive)
- Removedpromise@6.1.0(transitive)
Updatedgeneric-pool@^2.2.0
Updatedpromise@^7.0.1