@@ -105,7 +105,7 @@ module.exports.open = function (connStr, options, cb)
105
105
db = DBFactory ( options ) ;
106
106
107
107
db . open ( connStr , function ( err ) {
108
- cb ( err , db ) ;
108
+ cb && cb ( err , db ) ;
109
109
} ) ;
110
110
} ; // ibmdb.open
111
111
@@ -198,11 +198,11 @@ Database.prototype.open = function (connStr, cb) {
198
198
{
199
199
if ( cb )
200
200
{
201
- if ( err ) return cb ( err ) ;
202
-
203
- self . connected = true ;
204
-
205
- return cb ( err , result ) ;
201
+ if ( err ) cb ( err ) ;
202
+ else {
203
+ self . connected = true ;
204
+ cb ( err , result ) ;
205
+ }
206
206
}
207
207
else
208
208
{
@@ -334,7 +334,7 @@ Database.prototype.query = function (query, params, cb)
334
334
if ( result && typeof ( result ) === 'object' ) {
335
335
fetchMore ( ) ;
336
336
} else {
337
- cb ( initialErr , resultset ) ;
337
+ cb && cb ( initialErr , resultset ) ;
338
338
return next ( ) ;
339
339
}
340
340
@@ -496,7 +496,7 @@ Database.prototype.queryResult = function (query, params, cb)
496
496
{
497
497
if ( err )
498
498
{
499
- cb ( err , null ) ;
499
+ cb && cb ( err , null ) ;
500
500
return next ( ) ;
501
501
}
502
502
@@ -505,7 +505,7 @@ Database.prototype.queryResult = function (query, params, cb)
505
505
result . fetchMode = self . fetchMode ;
506
506
}
507
507
508
- cb ( err , result ) ;
508
+ cb && cb ( err , result ) ;
509
509
510
510
return next ( ) ;
511
511
} // function cbQuery
@@ -537,7 +537,7 @@ Database.prototype.queryResultSync = function (query, params)
537
537
if ( Array . isArray ( params ) )
538
538
{
539
539
var err = parseParams ( params ) ;
540
- if ( err ) cb ( err ) ;
540
+ if ( err ) cb && cb ( err ) ;
541
541
}
542
542
if ( sql . search ( / ^ c a l l / i) )
543
543
{
@@ -853,7 +853,7 @@ Database.prototype.columns = function(catalog, schema, table, column, callback)
853
853
result . fetchAll ( function ( err , data )
854
854
{
855
855
result . closeSync ( ) ;
856
- callback ( err , data ) ;
856
+ callback && callback ( err , data ) ;
857
857
return next ( ) ;
858
858
} ) ;
859
859
} ) ;
@@ -876,7 +876,7 @@ Database.prototype.tables = function(catalog, schema, table, type, callback)
876
876
result . fetchAll ( function ( err , data )
877
877
{
878
878
result . closeSync ( ) ;
879
- callback ( err , data ) ;
879
+ callback && callback ( err , data ) ;
880
880
return next ( ) ;
881
881
} ) ;
882
882
} ) ;
@@ -1021,11 +1021,6 @@ odbc.ODBCStatement.prototype.execute = function (params, cb)
1021
1021
if ( ! cb && typeof params !== 'function' )
1022
1022
{
1023
1023
deferred = Q . defer ( ) ;
1024
- // if(!params)
1025
- // {
1026
- // params = null;
1027
- // }
1028
-
1029
1024
}
1030
1025
1031
1026
self . queue = self . queue || new SimpleQueue ( ) ;
@@ -1285,7 +1280,7 @@ odbc.ODBCStatement.prototype.executeDirect = function (sql, cb)
1285
1280
1286
1281
self . queue . push ( function ( next ) {
1287
1282
self . _executeDirect ( sql , function ( err , result ) {
1288
- cb ( err , result ) ;
1283
+ cb && cb ( err , result ) ;
1289
1284
1290
1285
return next ( ) ;
1291
1286
} ) ;
@@ -1320,7 +1315,7 @@ odbc.ODBCStatement.prototype.executeNonQuery = function (params, cb)
1320
1315
{
1321
1316
if ( ! deferred )
1322
1317
{
1323
- if ( cb ) cb ( err ) ;
1318
+ cb && cb ( err ) ;
1324
1319
}
1325
1320
else
1326
1321
{
@@ -1332,7 +1327,7 @@ odbc.ODBCStatement.prototype.executeNonQuery = function (params, cb)
1332
1327
if ( err ) {
1333
1328
if ( ! deferred )
1334
1329
{
1335
- if ( cb ) cb ( err )
1330
+ cb && cb ( err )
1336
1331
}
1337
1332
else
1338
1333
{
@@ -1344,7 +1339,7 @@ odbc.ODBCStatement.prototype.executeNonQuery = function (params, cb)
1344
1339
self . _executeNonQuery ( function ( err , result ) {
1345
1340
if ( ! deferred )
1346
1341
{
1347
- if ( cb ) cb ( err , result ) ;
1342
+ cb && cb ( err , result ) ;
1348
1343
}
1349
1344
else
1350
1345
{
@@ -1366,7 +1361,7 @@ odbc.ODBCStatement.prototype.executeNonQuery = function (params, cb)
1366
1361
self . _executeNonQuery ( function ( err , result ) {
1367
1362
if ( ! deferred )
1368
1363
{
1369
- if ( cb ) cb ( err , result ) ;
1364
+ cb && cb ( err , result ) ;
1370
1365
}
1371
1366
else
1372
1367
{
@@ -1400,7 +1395,7 @@ odbc.ODBCStatement.prototype.prepare = function (sql, cb) {
1400
1395
1401
1396
self . queue . push ( function ( next ) {
1402
1397
self . _prepare ( sql , function ( err ) {
1403
- if ( cb ) cb ( err ) ;
1398
+ cb && cb ( err ) ;
1404
1399
1405
1400
return next ( ) ;
1406
1401
} ) ;
@@ -1420,7 +1415,7 @@ odbc.ODBCStatement.prototype.bind = function (ary, cb) {
1420
1415
if ( err && cb ) cb ( err ) ;
1421
1416
}
1422
1417
self . _bind ( ary , function ( err ) {
1423
- if ( cb ) cb ( err ) ;
1418
+ cb && cb ( err ) ;
1424
1419
1425
1420
//NOTE: we do not call next() here because
1426
1421
//we want to pop the next bind call only
@@ -1484,7 +1479,7 @@ Pool.prototype.open = function (connStr, callback)
1484
1479
db . lastUsed = null ;
1485
1480
self . usedPool [ connStr ] = self . usedPool [ connStr ] || [ ] ;
1486
1481
self . usedPool [ connStr ] . push ( db ) ;
1487
- callback ( null , db ) ;
1482
+ callback && callback ( null , db ) ;
1488
1483
}
1489
1484
else if ( ( self . maxPoolSize > 0 ) && ( self . poolSize >= self . maxPoolSize ) )
1490
1485
{
@@ -1498,12 +1493,12 @@ Pool.prototype.open = function (connStr, callback)
1498
1493
self . usedPool [ connStr ] = self . usedPool [ connStr ] || [ ] ;
1499
1494
self . usedPool [ connStr ] . push ( db ) ;
1500
1495
clearInterval ( interval ) ;
1501
- callback ( null , db ) ;
1496
+ callback && callback ( null , db ) ;
1502
1497
}
1503
1498
if ( timeout === 0 )
1504
1499
{
1505
1500
clearInterval ( interval ) ;
1506
- callback ( error , null ) ;
1501
+ callback && callback ( error , null ) ;
1507
1502
}
1508
1503
else
1509
1504
{
@@ -1525,7 +1520,7 @@ Pool.prototype.open = function (connStr, callback)
1525
1520
db . lastUsed = Date . now ( ) ;
1526
1521
//call back early, we can do the rest of this stuff after the client
1527
1522
//thinks that the connection is closed.
1528
- if ( cb ) cb ( null ) ;
1523
+ cb && cb ( null ) ;
1529
1524
1530
1525
// If this connection has some active transaction, rollback the
1531
1526
// transaction to free up the held resorces before moving back to
@@ -1565,7 +1560,7 @@ Pool.prototype.open = function (connStr, callback)
1565
1560
db . created = Date . now ( ) ;
1566
1561
self . usedPool [ connStr ] . push ( db ) ;
1567
1562
}
1568
- callback ( error , db ) ;
1563
+ callback && callback ( error , db ) ;
1569
1564
} ) ; //db.open
1570
1565
}
1571
1566
} ;
@@ -1650,7 +1645,7 @@ Pool.prototype.setConnectTimeout = function(timeout)
1650
1645
} ;
1651
1646
1652
1647
// Close idle connections
1653
- Pool . prototype . cleanUp = function ( connStr , callback ) {
1648
+ Pool . prototype . cleanUp = function ( connStr ) {
1654
1649
var self = this ;
1655
1650
if ( self . availablePool [ connStr ] . length < 2 ) return ;
1656
1651
0 commit comments