mssql 9.1.3 → 9.2.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.
|
@@ -7,48 +7,31 @@ const { IDS, INCREMENT } = require('../utils')
|
|
|
7
7
|
const shared = require('../shared')
|
|
8
8
|
const ConnectionError = require('../error/connection-error')
|
|
9
9
|
const { platform } = require('os')
|
|
10
|
+
const { buildConnectionString } = require('@tediousjs/connection-string')
|
|
10
11
|
|
|
11
12
|
const CONNECTION_DRIVER = ['darwin', 'linux'].includes(platform()) ? 'ODBC Driver 17 for SQL Server' : 'SQL Server Native Client 11.0'
|
|
12
|
-
const CONNECTION_STRING_PORT = `Driver=${CONNECTION_DRIVER};Server=#{server},#{port};Database=#{database};Uid=#{user};Pwd=#{password};Trusted_Connection=#{trusted};Encrypt=#{encrypt};`
|
|
13
|
-
const CONNECTION_STRING_NAMED_INSTANCE = `Driver=${CONNECTION_DRIVER};Server=#{server}\\#{instance};Database=#{database};Uid=#{user};Pwd=#{password};Trusted_Connection=#{trusted};Encrypt=#{encrypt};`
|
|
14
13
|
|
|
15
14
|
class ConnectionPool extends BaseConnectionPool {
|
|
16
15
|
_poolCreate () {
|
|
17
16
|
return new shared.Promise((resolve, reject) => {
|
|
18
|
-
let defaultConnectionString = CONNECTION_STRING_PORT
|
|
19
|
-
|
|
20
|
-
if (this.config.options.instanceName != null) {
|
|
21
|
-
defaultConnectionString = CONNECTION_STRING_NAMED_INSTANCE
|
|
22
|
-
}
|
|
23
|
-
|
|
24
17
|
this.config.requestTimeout = this.config.requestTimeout ?? this.config.timeout ?? 15000
|
|
25
18
|
|
|
26
19
|
const cfg = {
|
|
27
|
-
conn_str: this.config.connectionString
|
|
20
|
+
conn_str: this.config.connectionString,
|
|
28
21
|
conn_timeout: (this.config.connectionTimeout ?? this.config.timeout ?? 15000) / 1000
|
|
29
22
|
}
|
|
30
23
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
let val = this.config[key] || ''
|
|
43
|
-
// quote strings that contain '{' or '}' but not ones that start and end with them (assume they are already quoted)
|
|
44
|
-
if (val && typeof val === 'string' && !(val.startsWith('{') && val.endsWith('}')) && (val.indexOf('{') !== -1 || val.indexOf('}') !== -1)) {
|
|
45
|
-
// quote values in `{}` and escape any existing `}` chars
|
|
46
|
-
val = `{${val.replace(/}/g, '}}')}}`
|
|
47
|
-
}
|
|
48
|
-
return val
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
})
|
|
24
|
+
if (!this.config.connectionString) {
|
|
25
|
+
cfg.conn_str = buildConnectionString({
|
|
26
|
+
Driver: CONNECTION_DRIVER,
|
|
27
|
+
Server: this.config.options.instanceName ? `${this.config.server}\\${this.config.instanceName}` : `${this.config.server},${this.config.port}`,
|
|
28
|
+
Database: this.config.database,
|
|
29
|
+
Uid: this.config.user,
|
|
30
|
+
Pwd: this.config.password,
|
|
31
|
+
Trusted_Connection: !!this.config.options.trustedConnection,
|
|
32
|
+
Encrypt: !!this.config.options.encrypt
|
|
33
|
+
})
|
|
34
|
+
}
|
|
52
35
|
|
|
53
36
|
const connedtionId = INCREMENT.Connection++
|
|
54
37
|
debug('pool(%d): connection #%d created', IDS.get(this), connedtionId)
|
package/package.json
CHANGED
|
@@ -21,12 +21,12 @@
|
|
|
21
21
|
"azure",
|
|
22
22
|
"node-mssql"
|
|
23
23
|
],
|
|
24
|
-
"version": "9.
|
|
24
|
+
"version": "9.2.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.
|
|
29
|
+
"@tediousjs/connection-string": "^0.5.0",
|
|
30
30
|
"commander": "^11.0.0",
|
|
31
31
|
"debug": "^4.3.3",
|
|
32
32
|
"rfdc": "^1.3.0",
|