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.3.3 to 0.3.4

8

CHANGELOG.txt

@@ -0,1 +1,9 @@

v0.3.4 (2013-10-23)
-------------------
[new] Queries with input and output parameters.
v0.3.3 (2013-10-23)
-------------------
[new] Test connection when tedious pool is created.
v0.3.2 (2013-09-30)

@@ -2,0 +10,0 @@ -------------------

102

lib/msnodesql.js
// Generated by CoffeeScript 1.6.2
(function() {
var DECLARATIONS, TYPES, castParameter, createColumns, msnodesql, util,
var DECLARATIONS, TYPES, castParameter, createColumns, msnodesql, typeDeclaration, util,
__hasProp = {}.hasOwnProperty,

@@ -90,2 +90,17 @@ __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; };

typeDeclaration = function(type) {
switch (type) {
case TYPES.VarChar:
case TYPES.NVarChar:
case TYPES.Char:
case TYPES.NChar:
case TYPES.Xml:
case TYPES.Text:
case TYPES.NText:
return "" + type.name + " (MAX)";
default:
return type.name;
}
};
module.exports = function(Connection, Request) {

@@ -151,3 +166,3 @@ var MsnodesqlConnection, MsnodesqlRequest, _ref, _ref1;

MsnodesqlRequest.prototype.query = function(command, callback) {
var columns, name, param, recordset, recordsets, req, row, started,
var columns, handleOutput, input, name, output, param, recordset, recordsets, req, row, sets, started,
_this = this;

@@ -176,2 +191,49 @@

started = Date.now();
handleOutput = false;
if (!this.nested) {
input = (function() {
var _ref2, _results;
_ref2 = this.parameters;
_results = [];
for (name in _ref2) {
param = _ref2[name];
_results.push("@" + param.name + " " + (typeDeclaration(param.type)));
}
return _results;
}).call(this);
sets = (function() {
var _ref2, _results;
_ref2 = this.parameters;
_results = [];
for (name in _ref2) {
param = _ref2[name];
if (param.io === 1) {
_results.push("set @" + param.name + "=?");
}
}
return _results;
}).call(this);
output = (function() {
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 + "'");
}
}
return _results;
}).call(this);
if (input.length) {
command = "declare " + (input.join(',')) + ";" + (sets.join(';')) + ";" + command + ";";
}
if (output.length) {
command += "select " + (output.join(',')) + ";";
handleOutput = true;
}
}
req = this.connection["native"].queryRaw(command, (function() {

@@ -241,12 +303,30 @@ var _ref2, _results;

return req.once('done', function() {
var elapsed;
var elapsed, last, _ref2, _ref3;
if (_this.verbose && !_this.nested) {
if (row) {
console.log(util.inspect(row));
console.log("---------- --------------------");
if (!_this.nested) {
if (_this.verbose) {
if (row) {
console.log(util.inspect(row));
console.log("---------- --------------------");
}
}
elapsed = Date.now() - started;
console.log(" duration: " + elapsed + "ms");
console.log("---------- completed ----------");
if (handleOutput) {
last = (_ref2 = recordsets.pop()) != null ? _ref2[0] : void 0;
_ref3 = _this.parameters;
for (name in _ref3) {
param = _ref3[name];
if (!(param.io === 2)) {
continue;
}
param.value = last[param.name];
if (_this.verbose) {
console.log(" output: @" + param.name + ", " + param.type.name + ", " + param.value);
}
}
}
if (_this.verbose) {
elapsed = Date.now() - started;
console.log(" duration: " + elapsed + "ms");
console.log("---------- completed ----------");
}
}

@@ -273,3 +353,3 @@ return typeof callback === "function" ? callback(null, _this.multiple || _this.nested ? recordsets : recordsets[0]) : void 0;

if (param.io === 2) {
_results.push("@" + param.name + " " + param.type.name);
_results.push("@" + param.name + " " + (typeDeclaration(param.type)));
}

@@ -276,0 +356,0 @@ }

@@ -232,3 +232,3 @@ // Generated by CoffeeScript 1.6.2

return this.connection.pool.requestConnection(function(err, connection) {
var req;
var name, param, req, _ref2, _ref3;

@@ -273,2 +273,5 @@ if (!err) {

req.on('doneInProc', function(rowCount, more, rows) {
if (Object.keys(columns).length === 0) {
return;
}
Object.defineProperty(recordset, 'columns', {

@@ -282,2 +285,12 @@ enumerable: false,

});
req.on('returnValue', function(parameterName, value, metadata) {
if (_this.verbose) {
if (value === tds.TYPES.Null) {
console.log(" output: @" + parameterName + ", null");
} else {
console.log(" output: @" + parameterName + ", " + (_this.parameters[parameterName].type.name.toLowerCase()) + ", " + value);
}
}
return _this.parameters[parameterName].value = value === tds.TYPES.Null ? null : value;
});
req.on('row', function(columns) {

@@ -309,2 +322,24 @@ var col, exi, row, _i, _len;

});
_ref2 = _this.parameters;
for (name in _ref2) {
param = _ref2[name];
if (!(param.io === 1)) {
continue;
}
if (_this.verbose) {
if (param.value === tds.TYPES.Null) {
console.log(" input: @" + param.name + ", null");
} else {
console.log(" input: @" + param.name + ", " + (param.type.name.toLowerCase()) + ", " + param.value);
}
}
req.addParameter(param.name, getTediousType(param.type), param.value != null ? param.value : tds.TYPES.Null);
}
_ref3 = _this.parameters;
for (name in _ref3) {
param = _ref3[name];
if (param.io === 2) {
req.addOutputParameter(param.name, getTediousType(param.type));
}
}
if (_this.verbose) {

@@ -311,0 +346,0 @@ console.log("---------- response -----------");

2

package.json

@@ -15,3 +15,3 @@ {

],
"version": "0.3.3",
"version": "0.3.4",
"main": "index.js",

@@ -18,0 +18,0 @@ "repository": {

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