mssql 12.7.11 → 12.7.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -1
- package/lib/error/request-error.js +2 -4
- package/lib/msnodesqlv8/request.js +9 -7
- package/lib/utils.js +8 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
Supported TDS drivers:
|
|
8
8
|
|
|
9
9
|
- [Tedious][tedious-url] (pure JavaScript - Windows/macOS/Linux, default)
|
|
10
|
-
- [MSNodeSQLv8][msnodesqlv8-url] (Microsoft / Contributors Node V8 Driver for Node.js for SQL Server, v2-
|
|
10
|
+
- [MSNodeSQLv8][msnodesqlv8-url] (Microsoft / Contributors Node V8 Driver for Node.js for SQL Server, v2-v6 native - Windows or Linux/macOS 64 bits only)
|
|
11
11
|
|
|
12
12
|
## Installation
|
|
13
13
|
|
|
@@ -23,6 +23,8 @@ npm install mssql
|
|
|
23
23
|
npm install mssql msnodesqlv8
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
+
msnodesqlv8 6 needs Node.js 22 or later. On an older Node.js, install msnodesqlv8 5 (`npm install mssql msnodesqlv8@5`).
|
|
27
|
+
|
|
26
28
|
## SQL Server prerequisites
|
|
27
29
|
|
|
28
30
|
This package requires TCP/IP to connect to SQL Server, and you may need to enable this in your installation.
|
|
@@ -754,6 +756,8 @@ const sql = require('mssql/msnodesqlv8')
|
|
|
754
756
|
|
|
755
757
|
Note: If you use import into your lib to prepare your request (`const { VarChar } = require('mssql')`) you also need to upgrade all your types import into your code (`const { VarChar } = require('mssql/msnodesqlv8')`) or a `connection.on is not a function` error will be thrown.
|
|
756
758
|
|
|
759
|
+
msnodesqlv8 5 and earlier round `float` and `real` values, and `decimal` values with more than six decimal places, to six decimal places, output parameters included, so a value such as `1e-10` is read as `0`. `numeric`, `money` and `smallmoney` values are not affected. msnodesqlv8 6 reads them in full, as the tedious driver does; use its latest release.
|
|
760
|
+
|
|
757
761
|
|
|
758
762
|
**Extra options:**
|
|
759
763
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
const MSSQLError = require('./mssql-error')
|
|
4
|
+
const { stripOdbcPrefix } = require('../utils')
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Class RequestError.
|
|
@@ -43,10 +44,7 @@ class RequestError extends MSSQLError {
|
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
this.name = 'RequestError'
|
|
46
|
-
|
|
47
|
-
if (parsedMessage) {
|
|
48
|
-
this.message = parsedMessage[1]
|
|
49
|
-
}
|
|
47
|
+
this.message = stripOdbcPrefix(this.message)
|
|
50
48
|
}
|
|
51
49
|
}
|
|
52
50
|
|
|
@@ -4,7 +4,7 @@ const msnodesql = require('msnodesqlv8')
|
|
|
4
4
|
const debug = require('debug')('mssql:msv8')
|
|
5
5
|
const BaseRequest = require('../base/request')
|
|
6
6
|
const RequestError = require('../error/request-error')
|
|
7
|
-
const { IDS, objectHasProperty, assertSafeColumnName, assertSafeTypeName, assertSafeTypeSize, assertSafeProcedureName } = require('../utils')
|
|
7
|
+
const { IDS, objectHasProperty, assertSafeColumnName, assertSafeTypeName, assertSafeTypeSize, assertSafeProcedureName, stripOdbcPrefix } = require('../utils')
|
|
8
8
|
const { TYPES, DECLARATIONS, declare } = require('../datatypes')
|
|
9
9
|
const { PARSERS: UDT } = require('../udt')
|
|
10
10
|
const Table = require('../table')
|
|
@@ -637,11 +637,16 @@ class Request extends BaseRequest {
|
|
|
637
637
|
return true
|
|
638
638
|
}
|
|
639
639
|
|
|
640
|
+
// msnodesqlv8 6 ends a cancelled query only if it was paused when the cancel went out, or is
|
|
641
|
+
// never paused after it: one paused after its cancel is held for good, and holds its
|
|
642
|
+
// connection. So once a cancel has gone out, and until it is refused, the query is not paused
|
|
643
|
+
const cancelSent = () => cancelRequested && typeof req.getCancelSent === 'function' && req.getCancelSent()
|
|
644
|
+
|
|
640
645
|
// called with each row once it is complete
|
|
641
646
|
const pauseDriverAtEndOfBatch = () => {
|
|
642
647
|
if (driverPaused || rowsInRecordset % DRIVER_ROW_BATCH_SIZE !== 0) return
|
|
643
648
|
if (cancelDeferred && pauseAndCancelDriver()) return
|
|
644
|
-
if (this.stream && this.paused) {
|
|
649
|
+
if (this.stream && this.paused && !cancelSent()) {
|
|
645
650
|
driverPaused = true
|
|
646
651
|
req.pauseQuery()
|
|
647
652
|
}
|
|
@@ -650,7 +655,7 @@ class Request extends BaseRequest {
|
|
|
650
655
|
// until the first result set the driver has read nothing, so a stream paused before then,
|
|
651
656
|
// or before its query starts, holds it back at once
|
|
652
657
|
this._pauseStream = () => {
|
|
653
|
-
if (!columns && !driverPaused && !finished && reachable()) {
|
|
658
|
+
if (!columns && !driverPaused && !finished && !cancelSent() && reachable()) {
|
|
654
659
|
driverPaused = true
|
|
655
660
|
req.pauseQuery()
|
|
656
661
|
}
|
|
@@ -879,10 +884,7 @@ class Request extends BaseRequest {
|
|
|
879
884
|
req.on('info', (msg, more) => {
|
|
880
885
|
if (finished) return
|
|
881
886
|
|
|
882
|
-
|
|
883
|
-
if (parsedMessage) {
|
|
884
|
-
msg.message = parsedMessage[1]
|
|
885
|
-
}
|
|
887
|
+
msg.message = stripOdbcPrefix(msg.message)
|
|
886
888
|
|
|
887
889
|
const info = {
|
|
888
890
|
message: msg.message,
|
package/lib/utils.js
CHANGED
|
@@ -50,6 +50,13 @@ const TYPE_SIZE = /^\w*$/
|
|
|
50
50
|
// is the documented way to include one literally.
|
|
51
51
|
const escapesQuotedIdentifier = (name) => String(name).replace(/]]/g, '').includes(']')
|
|
52
52
|
|
|
53
|
+
// ODBC puts the components a message came through in front of it: the vendor and the driver,
|
|
54
|
+
// such as `[Microsoft][ODBC Driver 18 for SQL Server]`, then `[SQL Server]` when the server
|
|
55
|
+
// raised it. The driver manager's own messages name it instead, followed by a space on Windows,
|
|
56
|
+
// `[Microsoft][ODBC Driver Manager] `, and by nothing with unixODBC, `[unixODBC][Driver Manager]`.
|
|
57
|
+
// Only that one prefix is taken off, so what a PRINT or RAISERROR sent is kept as it was sent.
|
|
58
|
+
const ODBC_PREFIX = /^(?:\[Microsoft\]\[ODBC Driver Manager\] |\[unixODBC\]\[Driver Manager\]|\[Microsoft\]\[[^\]]+\](?:\[SQL Server\])?)/
|
|
59
|
+
|
|
53
60
|
module.exports = {
|
|
54
61
|
objectHasProperty: (object, property) => Object.prototype.hasOwnProperty.call(object, property),
|
|
55
62
|
isValidParameterName: (name) => {
|
|
@@ -107,6 +114,7 @@ module.exports = {
|
|
|
107
114
|
}
|
|
108
115
|
return column
|
|
109
116
|
},
|
|
117
|
+
stripOdbcPrefix: (message) => typeof message === 'string' ? message.replace(ODBC_PREFIX, '') : message,
|
|
110
118
|
INCREMENT,
|
|
111
119
|
IDS: {
|
|
112
120
|
get: IDS.get.bind(IDS),
|