Comparing version 2.0.0 to 2.1.0
@@ -0,1 +1,6 @@ | ||
v2.1.0 (2015-02-20) | ||
------------------- | ||
[new] Detailed SQL errors | ||
[fix] Precise detection of column data types | ||
v2.0.0 (2015-02-17) | ||
@@ -2,0 +7,0 @@ ------------------- |
@@ -1685,6 +1685,12 @@ // Generated by CoffeeScript 1.9.0 | ||
function RequestError(message, code) { | ||
var err; | ||
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, message.code); | ||
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', { | ||
@@ -1691,0 +1697,0 @@ value: message |
@@ -484,3 +484,9 @@ // Generated by CoffeeScript 1.9.0 | ||
req.once('error', function(err) { | ||
var elapsed; | ||
var e, elapsed; | ||
e = RequestError(err); | ||
if (/^\[Microsoft\]\[SQL Server Native Client 11\.0\]\[SQL Server\](.*)$/.exec(err.message)) { | ||
e.message = RegExp.$1; | ||
} | ||
e.number = err.code; | ||
e.code = 'EREQUEST'; | ||
if (_this.verbose && !_this.nested) { | ||
@@ -492,3 +498,3 @@ elapsed = Date.now() - started; | ||
} | ||
return typeof callback === "function" ? callback(RequestError(err)) : void 0; | ||
return typeof callback === "function" ? callback(e) : void 0; | ||
}); | ||
@@ -495,0 +501,0 @@ return req.once('done', function() { |
@@ -100,3 +100,3 @@ // Generated by CoffeeScript 1.9.0 | ||
getMssqlType = function(type) { | ||
getMssqlType = function(type, length) { | ||
switch (type) { | ||
@@ -116,4 +116,14 @@ case tds.TYPES.Char: | ||
case tds.TYPES.Int: | ||
return TYPES.Int; | ||
case tds.TYPES.IntN: | ||
return TYPES.Int; | ||
if (length === 8) { | ||
return TYPES.BigInt; | ||
} | ||
if (length === 4) { | ||
return TYPES.Int; | ||
} | ||
if (length === 2) { | ||
return TYPES.SmallInt; | ||
} | ||
return TYPES.TinyInt; | ||
case tds.TYPES.BigInt: | ||
@@ -129,9 +139,17 @@ return TYPES.BigInt; | ||
case tds.TYPES.Float: | ||
return TYPES.Float; | ||
case tds.TYPES.FloatN: | ||
return TYPES.Float; | ||
if (length === 8) { | ||
return TYPES.FloatN; | ||
} | ||
return TYPES.Real; | ||
case tds.TYPES.Real: | ||
return TYPES.Real; | ||
case tds.TYPES.Money: | ||
return TYPES.Money; | ||
case tds.TYPES.MoneyN: | ||
return TYPES.Money; | ||
if (length === 8) { | ||
return TYPES.Money; | ||
} | ||
return TYPES.SmallMoney; | ||
case tds.TYPES.SmallMoney: | ||
@@ -146,4 +164,8 @@ return TYPES.SmallMoney; | ||
case tds.TYPES.DateTime: | ||
return TYPES.DateTime; | ||
case tds.TYPES.DateTimeN: | ||
return TYPES.DateTime; | ||
if (length === 8) { | ||
return TYPES.DateTime; | ||
} | ||
return TYPES.SmallDateTime; | ||
case tds.TYPES.TimeN: | ||
@@ -190,3 +212,3 @@ return TYPES.Time; | ||
length: column.dataLength, | ||
type: getMssqlType(column.type), | ||
type: getMssqlType(column.type, column.dataLength), | ||
scale: column.scale, | ||
@@ -508,5 +530,7 @@ precision: column.precision, | ||
handleError = (function(_this) { | ||
return function(err) { | ||
var e; | ||
e = new RequestError(err.message, 'EREQUEST'); | ||
return function(info) { | ||
var e, err; | ||
err = new Error(info.message); | ||
err.info = info; | ||
e = RequestError(err, 'EREQUEST'); | ||
if (_this.stream) { | ||
@@ -542,3 +566,3 @@ _this.emit('error', e); | ||
if (err && err.message !== ((_ref1 = errors[errors.length - 1]) != null ? _ref1.message : void 0)) { | ||
err = RequestError(err); | ||
err = RequestError(err, 'EREQUEST'); | ||
if (_this.stream) { | ||
@@ -628,5 +652,7 @@ _this.emit('error', err); | ||
handleError = (function(_this) { | ||
return function(err) { | ||
var e; | ||
e = new RequestError(err.message, 'EREQUEST'); | ||
return function(info) { | ||
var e, err; | ||
err = new Error(info.message); | ||
err.info = info; | ||
e = RequestError(err, 'EREQUEST'); | ||
if (_this.stream) { | ||
@@ -662,3 +688,3 @@ _this.emit('error', e); | ||
if (err && err.message !== ((_ref1 = errors[errors.length - 1]) != null ? _ref1.message : void 0)) { | ||
err = RequestError(err); | ||
err = RequestError(err, 'EREQUEST'); | ||
if (_this.stream) { | ||
@@ -900,5 +926,7 @@ _this.emit('error', err); | ||
handleError = (function(_this) { | ||
return function(err) { | ||
var e; | ||
e = new RequestError(err.message, 'EREQUEST'); | ||
return function(info) { | ||
var e, err; | ||
err = new Error(info.message); | ||
err.info = info; | ||
e = RequestError(err, 'EREQUEST'); | ||
if (_this.stream) { | ||
@@ -934,3 +962,3 @@ _this.emit('error', e); | ||
if (err && err.message !== ((_ref1 = errors[errors.length - 1]) != null ? _ref1.message : void 0)) { | ||
err = RequestError(err); | ||
err = RequestError(err, 'EREQUEST'); | ||
if (_this.stream) { | ||
@@ -937,0 +965,0 @@ _this.emit('error', err); |
@@ -20,3 +20,3 @@ { | ||
], | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"main": "index.js", | ||
@@ -23,0 +23,0 @@ "repository": { |
@@ -15,3 +15,3 @@ # 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) | ||
- Serialization of Geography and Geometry CLR types | ||
- Injects original TDS modules with enhancements and bug fixes | ||
- Smart JS data type to SQL data type mapper | ||
- Support both Promises and standard callbacks | ||
@@ -24,3 +24,3 @@ | ||
## What's new in 2.0 (stable, npm) | ||
## What's new in 2.x (stable, npm) | ||
@@ -30,2 +30,3 @@ - Updated to latest Tedious 1.10 | ||
- [Pipe request to object stream](#pipe) | ||
- [Detailed SQL errors](#errors) | ||
- Transaction abort handling | ||
@@ -420,2 +421,3 @@ - Integrated type checks | ||
- ENOTBEGUN (`TransactionError`) - Transaction has not begun. | ||
- EABORT (`TransactionError`) - Transaction was aborted (by user or because of an error). | ||
@@ -555,2 +557,3 @@ --------------------------------------- | ||
- ENOTBEGUN (`TransactionError`) - Transaction has not begun. | ||
- EABORT (`TransactionError`) - Transaction was aborted (by user or because of an error). | ||
@@ -602,2 +605,3 @@ You can enable multiple recordsets in queries with the `request.multiple = true` command. | ||
- ENOTBEGUN (`TransactionError`) - Transaction has not begun. | ||
- EABORT (`TransactionError`) - Transaction was aborted (by user or because of an error). | ||
@@ -648,2 +652,3 @@ You can enable multiple recordsets in queries with the `request.multiple = true` command. | ||
- ENOTBEGUN (`TransactionError`) - Transaction has not begun. | ||
- EABORT (`TransactionError`) - Transaction was aborted (by user or because of an error). | ||
@@ -745,3 +750,3 @@ --------------------------------------- | ||
- **commit** - Dispatched on successful commit. | ||
- **rollback(aborted)** - Dispatched on successful rollback with an argument determining if the transaction was rolled back because of an error. | ||
- **rollback(aborted)** - Dispatched on successful rollback with an argument determining if the transaction was aborted (by user or because of an error). | ||
@@ -806,3 +811,3 @@ --------------------------------------- | ||
Rollback a transaction. | ||
Rollback a transaction. If the queue isn't empty, all queued requests will be canceled and the transaction will be marked as aborted. | ||
@@ -1197,3 +1202,3 @@ __Arguments__ | ||
Those errors are initialized in node-mssql module and its original stack can be cropped. You can always access original error with `err.originalError`. | ||
Those errors are initialized in node-mssql module and its original stack may be cropped. You can always access original error with `err.originalError`. | ||
@@ -1220,4 +1225,4 @@ SQL Server may generate more than one error for one request so you can access preceding errors with `err.precedingErrors`. | ||
`TransactionError` | EREQINPROG | Can't commit/rollback transaction. There is a request in progress. | ||
`TransactionError` | EABORT | Transaction has been aborted (because of XACT_ABORT set to ON). | ||
`RequestError` | EREQUEST | *Message from SQL Server* | ||
`TransactionError` | EABORT | Transaction has been aborted. | ||
`RequestError` | EREQUEST | Message from SQL Server. Error object contains additional details. | ||
`RequestError` | ECANCEL | Canceled. | ||
@@ -1233,2 +1238,13 @@ `RequestError` | ETIMEOUT | Request timeout. | ||
### Detailed SQL Errors | ||
SQL errors (`RequestError` with `err.code` equal to `EREQUEST`) contains additional details. | ||
- **err.number** - The error number. | ||
- **err.state** - The error state, used as a modifier to the error number. | ||
- **err.class** - The class (severity) of the error. A class of less than 10 indicates an informational message. Detailed explanation can be found [here](https://msdn.microsoft.com/en-us/library/dd304156.aspx). | ||
- **err.lineNumber** - The line number in the SQL batch or stored procedure that caused the error. Line numbers begin at 1; therefore, if the line number is not applicable to the message, the value of LineNumber will be 0. | ||
- **err.serverName** - The server name. | ||
- **err.procName** - The stored procedure name. | ||
<a name="meta" /> | ||
@@ -1235,0 +1251,0 @@ ## Metadata |
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
315051
4760
1412