Skip to content

Commit 62f73bc

Browse files
authored
Merge pull request #1750 from dhensby/pulls/connection-string
chore(deps): upgrade @tediousjs/connection-string to v1.0.0
2 parents cfea0bd + e1e18fa commit 62f73bc

4 files changed

Lines changed: 21 additions & 12 deletions

File tree

lib/base/connection-pool.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
const { EventEmitter } = require('node:events')
44
const debug = require('debug')('mssql:base')
5-
const { parseSqlConnectionString } = require('@tediousjs/connection-string')
5+
const { parse, MSSQL_SCHEMA } = require('@tediousjs/connection-string')
66
const tarn = require('tarn')
77
const { IDS } = require('../utils')
88
const ConnectionError = require('../error/connection-error')
@@ -99,6 +99,7 @@ class ConnectionPool extends EventEmitter {
9999
}
100100

101101
static _parseAuthenticationType (type, entries) {
102+
if (!type) return 'default'
102103
switch (type.toLowerCase()) {
103104
case 'active directory integrated':
104105
if (entries.includes('token')) {
@@ -121,7 +122,15 @@ class ConnectionPool extends EventEmitter {
121122
}
122123

123124
static _parseConnectionString (connectionString) {
124-
const parsed = parseSqlConnectionString(connectionString, true, true)
125+
const result = parse(connectionString)
126+
const parsed = result.toSchema(MSSQL_SCHEMA)
127+
// Include non-standard keys (client id, tenant id, token, msi endpoint, msi secret)
128+
// that are used for authentication but not part of the MSSQL schema
129+
for (const [key, value] of result) {
130+
if (!(key in parsed)) {
131+
parsed[key] = value
132+
}
133+
}
125134
return Object.entries(parsed).reduce((config, [key, value]) => {
126135
switch (key) {
127136
case 'application name':

lib/msnodesqlv8/connection-pool.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const { IDS, INCREMENT } = require('../utils')
77
const shared = require('../shared')
88
const ConnectionError = require('../error/connection-error')
99
const { platform } = require('node:os')
10-
const { buildConnectionString } = require('@tediousjs/connection-string')
10+
const { build } = require('@tediousjs/connection-string')
1111

1212
const DEFAULT_CONNECTION_DRIVER = ['darwin', 'linux'].includes(platform()) ? 'ODBC Driver 17 for SQL Server' : 'SQL Server Native Client 11.0'
1313

@@ -22,7 +22,7 @@ class ConnectionPool extends BaseConnectionPool {
2222
}
2323

2424
if (!this.config.connectionString) {
25-
cfg.conn_str = buildConnectionString({
25+
cfg.conn_str = build({
2626
Driver: this.config.driver && this.config.driver !== 'msnodesqlv8' ? this.config.driver : DEFAULT_CONNECTION_DRIVER,
2727
Server: this.config.options.instanceName ? `${this.config.server}\\${this.config.options.instanceName}` : `${this.config.server},${this.config.port}`,
2828
Database: this.config.database,

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
},
3535
"license": "MIT",
3636
"dependencies": {
37-
"@tediousjs/connection-string": "^0.6.0",
37+
"@tediousjs/connection-string": "^1.0.0",
3838
"commander": "^11.0.0",
3939
"debug": "^4.3.3",
4040
"tarn": "^3.0.2",

0 commit comments

Comments
 (0)