mssql 8.1.1 → 8.1.4

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,16 @@
1
+ v8.1.4 (2022-08-18)
2
+ -------------------
3
+ [fix] fix regression in requestTimout option not accepting `0` as a value ([#1421](https://github.com/tediousjs/node-mssql/pull/1421))
4
+
5
+ v8.1.3 (2022-08-08)
6
+ -------------------
7
+ [fix] requestTimeout correctly resolved ([#1398](https://github.com/tediousjs/node-mssql/pull/1398))
8
+ [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))
9
+
10
+ v8.1.2 (2022-05-27)
11
+ -------------------
12
+ [fix] quote identifiers in table constraint declaration ([#1397](https://github.com/tediousjs/node-mssql/pull/1397))
13
+
1
14
  v8.1.1 (2022-05-18)
2
15
  -------------------
3
16
  [fix] quote identifiers in table primary keys ([#1394](https://github.com/tediousjs/node-mssql/pull/1394))
@@ -30,6 +43,10 @@ v8.0.0 (2022-01-30)
30
43
  [removed] Remove connection string parser helpers ((#1342)[https://github.com/tediousjs/node-mssql/pull/1342])
31
44
  [removed] Remove deprecated pool properties ((#1359)[https://github.com/tediousjs/node-mssql/pull/1359])
32
45
 
46
+ v7.3.5 (2022-05-27)
47
+ -------------------
48
+ [fix] quote identifiers in table constraint declaration ([#1397](https://github.com/tediousjs/node-mssql/pull/1397))
49
+
33
50
  v7.3.4 (2022-05-18)
34
51
  -------------------
35
52
  [fix] msnodesqlv8.js file was missing from previous release
@@ -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}
@@ -12,6 +12,14 @@ const CONNECTION_DRIVER = ['darwin', 'linux'].includes(platform()) ? 'ODBC Drive
12
12
  const CONNECTION_STRING_PORT = `Driver=${CONNECTION_DRIVER};Server=#{server},#{port};Database=#{database};Uid=#{user};Pwd=#{password};Trusted_Connection=#{trusted};Encrypt=#{encrypt};`
13
13
  const CONNECTION_STRING_NAMED_INSTANCE = `Driver=${CONNECTION_DRIVER};Server=#{server}\\#{instance};Database=#{database};Uid=#{user};Pwd=#{password};Trusted_Connection=#{trusted};Encrypt=#{encrypt};`
14
14
 
15
+ function firstDefined () {
16
+ for (let i = 0; i < arguments.length; i++) {
17
+ if (typeof arguments[i] !== 'undefined') {
18
+ return arguments[i]
19
+ }
20
+ }
21
+ }
22
+
15
23
  class ConnectionPool extends BaseConnectionPool {
16
24
  _poolCreate () {
17
25
  return new shared.Promise((resolve, reject) => {
@@ -21,13 +29,11 @@ class ConnectionPool extends BaseConnectionPool {
21
29
  defaultConnectionString = CONNECTION_STRING_NAMED_INSTANCE
22
30
  }
23
31
 
24
- if (this.config.requestTimeout == null) {
25
- this.config.requestTimeout = 15000
26
- }
32
+ this.config.requestTimeout = firstDefined(this.config.requestTimeout, this.config.timeout, 15000)
27
33
 
28
34
  const cfg = {
29
35
  conn_str: this.config.connectionString || defaultConnectionString,
30
- conn_timeout: (this.config.connectionTimeout || 15000) / 1000
36
+ conn_timeout: firstDefined(this.config.connectionTimeout, this.config.timeout, 15000) / 1000
31
37
  }
32
38
 
33
39
  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
 
@@ -7,6 +7,14 @@ const { IDS } = require('../utils')
7
7
  const shared = require('../shared')
8
8
  const ConnectionError = require('../error/connection-error')
9
9
 
10
+ function firstDefined () {
11
+ for (let i = 0; i < arguments.length; i++) {
12
+ if (typeof arguments[i] !== 'undefined') {
13
+ return arguments[i]
14
+ }
15
+ }
16
+ }
17
+
10
18
  class ConnectionPool extends BaseConnectionPool {
11
19
  _poolCreate () {
12
20
  return new shared.Promise((resolve, reject) => {
@@ -36,8 +44,8 @@ class ConnectionPool extends BaseConnectionPool {
36
44
 
37
45
  cfg.options.database = cfg.options.database || this.config.database
38
46
  cfg.options.port = cfg.options.port || this.config.port
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
47
+ cfg.options.connectTimeout = firstDefined(cfg.options.connectTimeout, this.config.connectionTimeout, this.config.timeout, 15000)
48
+ cfg.options.requestTimeout = firstDefined(cfg.options.requestTimeout, this.config.requestTimeout, this.config.timeout, 15000)
41
49
  cfg.options.tdsVersion = cfg.options.tdsVersion || '7_4'
42
50
  cfg.options.rowCollectionOnDone = cfg.options.rowCollectionOnDone || false
43
51
  cfg.options.rowCollectionOnRequestCompletion = cfg.options.rowCollectionOnRequestCompletion || false
package/package.json CHANGED
@@ -21,7 +21,7 @@
21
21
  "azure",
22
22
  "node-mssql"
23
23
  ],
24
- "version": "8.1.1",
24
+ "version": "8.1.4",
25
25
  "main": "index.js",
26
26
  "repository": "github:tediousjs/node-mssql",
27
27
  "license": "MIT",