32
32
33
33
'use strict' ;
34
34
35
- const sql = require ( " mssql" ) ;
35
+ const sql = require ( ' mssql' ) ;
36
36
const config = require ( 'config' ) ;
37
37
const connectorUtilities = require ( './connectorUtilities' ) ;
38
38
const utils = require ( '../../../Common/sources/utils' ) ;
@@ -50,12 +50,21 @@ const connectionConfiguration = {
50
50
database : configSql . get ( 'dbName' ) ,
51
51
pool : {
52
52
max : configSql . get ( 'connectionlimit' ) ,
53
- min : 0 ,
54
- idleTimeoutMillis : 30000
53
+ min : 0
55
54
}
56
55
} ;
57
56
const additionalOptions = configSql . get ( 'msSqlExtraOptions' ) ;
58
- const configuration = Object . assign ( { } , connectionConfiguration , additionalOptions ) ;
57
+
58
+ const mergedObjects = { } ;
59
+ for ( const option in additionalOptions ) {
60
+ if ( connectionConfiguration . hasOwnProperty ( option ) && typeof connectionConfiguration [ option ] === 'object' ) {
61
+ mergedObjects [ option ] = Object . assign ( { } , connectionConfiguration [ option ] , additionalOptions [ option ] ) ;
62
+ } else {
63
+ mergedObjects [ option ] = additionalOptions [ option ] ;
64
+ }
65
+ }
66
+
67
+ const configuration = Object . assign ( { } , connectionConfiguration , mergedObjects ) ;
59
68
60
69
const placeholderPrefix = 'ph_' ;
61
70
@@ -72,15 +81,15 @@ function errorHandle(message, error, ctx) {
72
81
function dataType ( value ) {
73
82
let type = sql . TYPES . NChar ( 1 ) ;
74
83
switch ( typeof value ) {
75
- case " number" : {
84
+ case ' number' : {
76
85
type = sql . TYPES . Decimal ( 18 , 0 ) ;
77
86
break ;
78
87
}
79
- case " string" : {
88
+ case ' string' : {
80
89
type = sql . TYPES . NVarChar ( sql . MAX ) ;
81
90
break ;
82
91
}
83
- case " object" : {
92
+ case ' object' : {
84
93
if ( value instanceof Date ) {
85
94
type = sql . TYPES . DateTime ( ) ;
86
95
}
0 commit comments