22
33const { EventEmitter } = require ( 'node:events' )
44const debug = require ( 'debug' ) ( 'mssql:base' )
5- const { parseSqlConnectionString } = require ( '@tediousjs/connection-string' )
5+ const { parse , MSSQL_SCHEMA } = require ( '@tediousjs/connection-string' )
66const tarn = require ( 'tarn' )
77const { IDS } = require ( '../utils' )
88const 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' :
0 commit comments