@@ -113,14 +113,19 @@ function parameterizeQuery(query, params, callback) {
113
113
} ) ;
114
114
}
115
115
116
+ function isSafeToUseJavaBridge ( sql ) {
117
+ var lowerSQL = sql . toLowerCase ( ) ;
118
+ return lowerSQL . indexOf ( "insert" ) === - 1 && lowerSQL . indexOf ( "update" ) === - 1 && lowerSQL . indexOf ( "delete" ) === - 1 ;
119
+ }
120
+
116
121
function executePreparedStatement ( api , sql , parameters , connection , next , db ) {
117
122
async . waterfall ( [
118
123
function ( cb ) {
119
124
parameterizeQuery ( sql , parameters , cb ) ;
120
125
} , function ( parametrizedQuery , cb ) {
121
126
sql = parametrizedQuery ;
122
127
123
- if ( api . helper . readTransaction ) {
128
+ if ( isSafeToUseJavaBridge ( sql ) && api . helper . readTransaction ) {
124
129
api . log ( "Calling Java Bridge" , "debug" ) ;
125
130
126
131
api . log ( sql , "debug" ) ;
@@ -304,8 +309,13 @@ exports.dataAccess = function (api, next) {
304
309
return ;
305
310
}
306
311
307
- if ( ! api . helper . readTransaction ) {
312
+ sql = queries [ queryName ] . sql ;
313
+
314
+ if ( ! isSafeToUseJavaBridge ( sql ) || ! api . helper . readTransaction ) {
308
315
connection = connectionMap [ queries [ queryName ] . db ] ;
316
+ api . log ( "######### MD #########" , "info" ) ;
317
+ api . log ( JSON . stringify ( connectionMap ) , "info" ) ;
318
+ api . log ( queryName , "info" ) ;
309
319
error = helper . checkObject ( connection , "connection" ) ;
310
320
}
311
321
@@ -314,7 +324,6 @@ exports.dataAccess = function (api, next) {
314
324
return ;
315
325
}
316
326
317
- sql = queries [ queryName ] . sql ;
318
327
if ( ! sql ) {
319
328
api . log ( 'Unregistered query ' + queryName + ' is asked for.' , 'error' ) ;
320
329
next ( 'The query for name ' + queryName + ' is not registered' ) ;
@@ -354,7 +363,7 @@ exports.dataAccess = function (api, next) {
354
363
return ;
355
364
}
356
365
357
- if ( ! api . helper . readTransaction ) {
366
+ if ( ! isSafeToUseJavaBridge ( sql ) || ! api . helper . readTransaction ) {
358
367
connection = connectionMap [ dbName ] ;
359
368
error = helper . checkObject ( connection , "connection" ) ;
360
369
}
0 commit comments