@@ -4,20 +4,27 @@ import { log } from './logging-service';
44import { logToOutput } from './output-service' ;
55import { KnexClientType } from '../types' ;
66
7- export async function getConnectionFor ( description : string , dialect : KnexClientType , host : string , port : number , username : string , password : string , database : string | undefined = undefined , notifyOnError = true ) : Promise < knexlib . Knex | undefined > {
7+ export async function getConnectionFor ( description : string , dialect : KnexClientType , host : string , port : number , username : string , password : string , database : string | undefined = undefined , notifyOnError = true , options ?: Record < string , unknown > ) : Promise < knexlib . Knex | undefined > {
88
99 log ( `Connector - ${ description } ` , `Attempting to connect to database: dialect=${ dialect } , host=${ host } , port=${ port } , username=${ username } , database=${ database ? String ( database [ 0 ] ) + '*****' : '<not-provided>' } ` ) ;
1010
1111 try {
12+ const connection : any = {
13+ host : host ? String ( host ) : host ,
14+ port : port ? Number ( port ) : port ,
15+ user : username ? String ( username ) : username ,
16+ password : password ? String ( password ) : password ,
17+ database : database ? String ( database ) : database ,
18+ } ;
19+
20+ // Add options to connection config for MSSQL
21+ if ( dialect === 'mssql' && options ) {
22+ connection . options = options ;
23+ }
24+
1225 const knex = knexlib . knex ( {
1326 client : dialect ,
14- connection : {
15- host : host ? String ( host ) : host ,
16- port : port ? Number ( port ) : port ,
17- user : username ? String ( username ) : username ,
18- password : password ? String ( password ) : password ,
19- database : database ? String ( database ) : database ,
20- } ,
27+ connection,
2128 } ) ;
2229
2330 return knex
0 commit comments