mssql 12.7.8 → 12.7.9
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 +6 -1
- package/lib/base/prepared-statement.js +9 -1
- package/lib/base/transaction.js +10 -2
- package/lib/msnodesqlv8/request.js +6 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1382,7 +1382,9 @@ transaction.begin(err => {
|
|
|
1382
1382
|
```
|
|
1383
1383
|
|
|
1384
1384
|
__Errors__
|
|
1385
|
+
- ENOCONN (`TransactionError`) - No connection is specified for that transaction.
|
|
1385
1386
|
- ENOTOPEN (`ConnectionError`) - Connection not yet open.
|
|
1387
|
+
- ECONNCLOSED (`ConnectionError`) - Connection is closed.
|
|
1386
1388
|
- EALREADYBEGUN (`TransactionError`) - Transaction has already begun.
|
|
1387
1389
|
|
|
1388
1390
|
If the transaction fails to begin once it has a connection, the error is a `TransactionError`, with the error it comes from as its `originalError`. The connection goes back to the pool, and the transaction can be begun again. A connection that may have sent the request to begin the transaction is closed rather than lent out again, as the server may have begun the transaction even though the request failed (for example, when it timed out).
|
|
@@ -1544,7 +1546,8 @@ ps.prepare('select @param as value', err => {
|
|
|
1544
1546
|
```
|
|
1545
1547
|
|
|
1546
1548
|
__Errors__
|
|
1547
|
-
-
|
|
1549
|
+
- ENOCONN (`PreparedStatementError`) - No connection is specified for that prepared statement.
|
|
1550
|
+
- ECONNCLOSED (`ConnectionError`) - Connection is closed.
|
|
1548
1551
|
- EALREADYPREPARED (`PreparedStatementError`) - Statement is already prepared.
|
|
1549
1552
|
- ENOTBEGUN (`TransactionError`) - Transaction has not begun.
|
|
1550
1553
|
|
|
@@ -2221,6 +2224,7 @@ Name | Code | Message
|
|
|
2221
2224
|
`TransactionError` | EALREADYBEGUN | Transaction has already begun.
|
|
2222
2225
|
`TransactionError` | EREQINPROG | Can't commit/rollback transaction or acquire connection for the request. There is a request in progress.
|
|
2223
2226
|
`TransactionError` | EABORT | Transaction has been aborted.
|
|
2227
|
+
`TransactionError` | ENOCONN | No connection is specified for that transaction.
|
|
2224
2228
|
`RequestError` | EREQUEST | Message from SQL Server. Error object contains additional details.
|
|
2225
2229
|
`RequestError` | ECANCEL | Cancelled.
|
|
2226
2230
|
`RequestError` | ETIMEOUT | Request timeout.
|
|
@@ -2231,6 +2235,7 @@ Name | Code | Message
|
|
|
2231
2235
|
`PreparedStatementError` | EINJECT | Parameter name is not a valid identifier.
|
|
2232
2236
|
`PreparedStatementError` | EALREADYPREPARED | Statement is already prepared.
|
|
2233
2237
|
`PreparedStatementError` | ENOTPREPARED | Statement is not prepared.
|
|
2238
|
+
`PreparedStatementError` | ENOCONN | No connection is specified for that prepared statement.
|
|
2234
2239
|
|
|
2235
2240
|
### Detailed SQL Errors
|
|
2236
2241
|
|
|
@@ -4,7 +4,7 @@ const debug = require('debug')('mssql:base')
|
|
|
4
4
|
const { EventEmitter } = require('node:events')
|
|
5
5
|
const { IDS, objectHasProperty, getPoolId, isValidParameterName } = require('../utils')
|
|
6
6
|
const globalConnection = require('../global-connection')
|
|
7
|
-
const { TransactionError, PreparedStatementError } = require('../error')
|
|
7
|
+
const { ConnectionError, TransactionError, PreparedStatementError } = require('../error')
|
|
8
8
|
const shared = require('../shared')
|
|
9
9
|
const { TYPES, declare } = require('../datatypes')
|
|
10
10
|
const { CHANNELS, tracePromise, traceCallback, publish } = require('../diagnostics')
|
|
@@ -244,6 +244,14 @@ class PreparedStatement extends EventEmitter {
|
|
|
244
244
|
|
|
245
245
|
this.statement = statement || this.statement
|
|
246
246
|
|
|
247
|
+
if (!this.parent) {
|
|
248
|
+
return setImmediate(callback, new PreparedStatementError('No connection is specified for that prepared statement.', 'ENOCONN'))
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
if (!this.parent.connected) {
|
|
252
|
+
return setImmediate(callback, new ConnectionError('Connection is closed.', 'ECONNCLOSED'))
|
|
253
|
+
}
|
|
254
|
+
|
|
247
255
|
this.parent.acquire(this, (err, connection, config) => {
|
|
248
256
|
if (err) return callback(err)
|
|
249
257
|
|
package/lib/base/transaction.js
CHANGED
|
@@ -4,7 +4,7 @@ const debug = require('debug')('mssql:base')
|
|
|
4
4
|
const { EventEmitter } = require('node:events')
|
|
5
5
|
const { IDS, getPoolId } = require('../utils')
|
|
6
6
|
const globalConnection = require('../global-connection')
|
|
7
|
-
const { TransactionError } = require('../error')
|
|
7
|
+
const { ConnectionError, TransactionError } = require('../error')
|
|
8
8
|
const shared = require('../shared')
|
|
9
9
|
const ISOLATION_LEVEL = require('../isolationlevel')
|
|
10
10
|
const { CHANNELS, publish } = require('../diagnostics')
|
|
@@ -52,7 +52,7 @@ class Transaction extends EventEmitter {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
get connected () {
|
|
55
|
-
return this.parent.connected
|
|
55
|
+
return this.parent ? this.parent.connected : false
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
/**
|
|
@@ -164,6 +164,14 @@ class Transaction extends EventEmitter {
|
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
+
if (!this.parent) {
|
|
168
|
+
return setImmediate(callback, new TransactionError('No connection is specified for that transaction.', 'ENOCONN'))
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
if (!this.parent.connected) {
|
|
172
|
+
return setImmediate(callback, new ConnectionError('Connection is closed.', 'ECONNCLOSED'))
|
|
173
|
+
}
|
|
174
|
+
|
|
167
175
|
setImmediate(callback)
|
|
168
176
|
}
|
|
169
177
|
|
|
@@ -248,10 +248,14 @@ class Request extends BaseRequest {
|
|
|
248
248
|
|
|
249
249
|
this.parent.release(connection)
|
|
250
250
|
|
|
251
|
+
// msnodesqlv8's table manager calls `done` from within promise chains, which would
|
|
252
|
+
// catch what the caller's callback throws and pass it back here as the driver's
|
|
253
|
+
// error, to be dropped. The caller is called back outside them, so that what its
|
|
254
|
+
// callback throws reaches the process as it would from any other callback.
|
|
251
255
|
if (err) {
|
|
252
|
-
callback
|
|
256
|
+
process.nextTick(callback, err)
|
|
253
257
|
} else {
|
|
254
|
-
callback
|
|
258
|
+
process.nextTick(callback, null, table.rows.length)
|
|
255
259
|
}
|
|
256
260
|
}
|
|
257
261
|
|