mssql 8.1.1 → 9.0.0

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/CHANGELOG.txt CHANGED
@@ -1,3 +1,17 @@
1
+ v9.0.0 (2022-08-10)
2
+ -------------------
3
+ [change] Upgrade tedious to v15 ([#1417](https://github.com/tediousjs/node-mssql/pull/1417))
4
+ [removed] Removed NodeJS 10 & 12 support ([#1417](https://github.com/tediousjs/node-mssql/pull/1417))
5
+
6
+ v8.1.3 (2022-08-08)
7
+ -------------------
8
+ [fix] requestTimeout correctly resolved ([#1398](https://github.com/tediousjs/node-mssql/pull/1398))
9
+ [fix] Forcibly deny use of `useColumnNames` tedious config option that can be passed in the config object ([#1416](https://github.com/tediousjs/node-mssql/pull/1416))
10
+
11
+ v8.1.2 (2022-05-27)
12
+ -------------------
13
+ [fix] quote identifiers in table constraint declaration ([#1397](https://github.com/tediousjs/node-mssql/pull/1397))
14
+
1
15
  v8.1.1 (2022-05-18)
2
16
  -------------------
3
17
  [fix] quote identifiers in table primary keys ([#1394](https://github.com/tediousjs/node-mssql/pull/1394))
@@ -30,6 +44,10 @@ v8.0.0 (2022-01-30)
30
44
  [removed] Remove connection string parser helpers ((#1342)[https://github.com/tediousjs/node-mssql/pull/1342])
31
45
  [removed] Remove deprecated pool properties ((#1359)[https://github.com/tediousjs/node-mssql/pull/1359])
32
46
 
47
+ v7.3.5 (2022-05-27)
48
+ -------------------
49
+ [fix] quote identifiers in table constraint declaration ([#1397](https://github.com/tediousjs/node-mssql/pull/1397))
50
+
33
51
  v7.3.4 (2022-05-18)
34
52
  -------------------
35
53
  [fix] msnodesqlv8.js file was missing from previous release
package/README.md CHANGED
@@ -2025,6 +2025,11 @@ request.query('select @myval as myval', (err, result) => {
2025
2025
  - If you're facing problems with connecting SQL Server 2000, try setting the default TDS version to 7.1 with `config.options.tdsVersion = '7_1'` ([issue](https://github.com/tediousjs/node-mssql/issues/36))
2026
2026
  - If you're executing a statement longer than 4000 chars on SQL Server 2000, always use [batch](#batch-batch-callback) instead of [query](#query-command-callback) ([issue](https://github.com/tediousjs/node-mssql/issues/68))
2027
2027
 
2028
+ ## 8.x to 7.x changes
2029
+
2030
+ - Upgraded to tedious version 15
2031
+ - Dropped support for Node version < 12
2032
+
2028
2033
  ## 7.x to 8.x changes
2029
2034
 
2030
2035
  - Upgraded to tedious version 14
@@ -8,6 +8,7 @@ const { IDS } = require('../utils')
8
8
  const ConnectionError = require('../error/connection-error')
9
9
  const shared = require('../shared')
10
10
  const clone = require('rfdc/default')
11
+ const { MSSQLError } = require('../error')
11
12
 
12
13
  /**
13
14
  * Class ConnectionPool.
@@ -68,6 +69,14 @@ class ConnectionPool extends EventEmitter {
68
69
  this.config.options.instanceName = RegExp.$2
69
70
  }
70
71
 
72
+ if (typeof this.config.options.useColumnNames !== 'undefined' && this.config.options.useColumnNames !== true) {
73
+ const ex = new MSSQLError('Invalid options `useColumnNames`, use `arrayRowMode` instead')
74
+ if (typeof callback === 'function') {
75
+ return setImmediate(callback, ex)
76
+ }
77
+ throw ex
78
+ }
79
+
71
80
  if (typeof callback === 'function') {
72
81
  this.connect(callback)
73
82
  }
@@ -48,7 +48,7 @@ class Request extends EventEmitter {
48
48
  }
49
49
 
50
50
  /**
51
- * Generate sql string and set imput parameters from tagged template string.
51
+ * Generate sql string and set input parameters from tagged template string.
52
52
  *
53
53
  * @param {Template literal} template
54
54
  * @return {String}
@@ -21,13 +21,11 @@ class ConnectionPool extends BaseConnectionPool {
21
21
  defaultConnectionString = CONNECTION_STRING_NAMED_INSTANCE
22
22
  }
23
23
 
24
- if (this.config.requestTimeout == null) {
25
- this.config.requestTimeout = 15000
26
- }
24
+ this.config.requestTimeout = this.config.requestTimeout || this.config.timeout || 15000
27
25
 
28
26
  const cfg = {
29
27
  conn_str: this.config.connectionString || defaultConnectionString,
30
- conn_timeout: (this.config.connectionTimeout || 15000) / 1000
28
+ conn_timeout: (this.config.connectionTimeout || this.config.timeout || 15000) / 1000
31
29
  }
32
30
 
33
31
  cfg.conn_str = cfg.conn_str.replace(/#{([^}]*)}/g, (p) => {
@@ -369,7 +369,7 @@ class Request extends BaseRequest {
369
369
  }
370
370
  const param = this.parameters[name]
371
371
  if (param.io === 1 || (param.io === 2 && param.value)) {
372
- params.push(castParameter(param.value, param.type, param))
372
+ params.push(castParameter(param.value, param.type))
373
373
  }
374
374
  }
375
375
 
package/lib/table.js CHANGED
@@ -116,7 +116,7 @@ Table.prototype.declare = function declare () {
116
116
  return def.join(' ')
117
117
  })
118
118
 
119
- const constraint = pkey.length > 1 ? `, constraint PK_${this.temporary ? this.name.substr(1) : this.name} primary key (${pkey.join(', ')})` : ''
119
+ const constraint = pkey.length > 1 ? `, constraint [PK_${this.temporary ? this.name.substr(1) : this.name}] primary key (${pkey.join(', ')})` : ''
120
120
  return `create table ${this.path} (${cols.join(', ')}${constraint})`
121
121
  }
122
122
 
@@ -37,7 +37,7 @@ class ConnectionPool extends BaseConnectionPool {
37
37
  cfg.options.database = cfg.options.database || this.config.database
38
38
  cfg.options.port = cfg.options.port || this.config.port
39
39
  cfg.options.connectTimeout = cfg.options.connectTimeout || this.config.connectionTimeout || this.config.timeout || 15000
40
- cfg.options.requestTimeout = cfg.options.requestTimeout || this.config.requestTimeout != null ? this.config.requestTimeout : 15000
40
+ cfg.options.requestTimeout = cfg.options.requestTimeout || this.config.requestTimeout || this.config.timeout || 15000
41
41
  cfg.options.tdsVersion = cfg.options.tdsVersion || '7_4'
42
42
  cfg.options.rowCollectionOnDone = cfg.options.rowCollectionOnDone || false
43
43
  cfg.options.rowCollectionOnRequestCompletion = cfg.options.rowCollectionOnRequestCompletion || false
@@ -442,12 +442,15 @@ class Request extends BaseRequest {
442
442
  debug('request(%d): query', IDS.get(this), command)
443
443
 
444
444
  const req = new tds.Request(command, err => {
445
- // to make sure we handle no-sql errors as well
446
- if (err && (!errors.length || (errors.length && err.message !== errors[errors.length - 1].message))) {
447
- err = new RequestError(err, 'EREQUEST')
448
- if (this.stream) this.emit('error', err)
449
- errors.push(err)
450
- }
445
+ // tedious v15 has started using AggregateErrors to wrap multiple errors into single error objects
446
+ (err?.errors ? err.errors : [err]).forEach((e, i, { length }) => {
447
+ // to make sure we handle no-sql errors as well
448
+ if (e && (!errors.length || (errors.length && errors.length >= length && e.message !== errors[errors.length - length + i].message))) {
449
+ e = new RequestError(e, 'EREQUEST')
450
+ if (this.stream) this.emit('error', e)
451
+ errors.push(e)
452
+ }
453
+ })
451
454
 
452
455
  // process batch outputs
453
456
  if (batchHasOutput) {
package/lib/utils.js CHANGED
@@ -9,7 +9,7 @@ const INCREMENT = {
9
9
 
10
10
  module.exports = {
11
11
  objectHasProperty: (object, property) => Object.prototype.hasOwnProperty.call(object, property),
12
- INCREMENT: INCREMENT,
12
+ INCREMENT,
13
13
  IDS: {
14
14
  get: IDS.get.bind(IDS),
15
15
  add: (object, type, id) => {
package/package.json CHANGED
@@ -21,21 +21,21 @@
21
21
  "azure",
22
22
  "node-mssql"
23
23
  ],
24
- "version": "8.1.1",
24
+ "version": "9.0.0",
25
25
  "main": "index.js",
26
26
  "repository": "github:tediousjs/node-mssql",
27
27
  "license": "MIT",
28
28
  "dependencies": {
29
- "@tediousjs/connection-string": "^0.3.0",
30
- "commander": "^9.1.0",
29
+ "@tediousjs/connection-string": "^0.4.1",
30
+ "commander": "^9.4.0",
31
31
  "debug": "^4.3.3",
32
32
  "rfdc": "^1.3.0",
33
33
  "tarn": "^3.0.2",
34
- "tedious": "^14.0.0"
34
+ "tedious": "^15.0.1"
35
35
  },
36
36
  "devDependencies": {
37
- "mocha": "^9.1.3",
38
- "standard": "^16.0.4"
37
+ "mocha": "^10.0.0",
38
+ "standard": "^17.0.0"
39
39
  },
40
40
  "engines": {
41
41
  "node": ">=10"