Skip to content

Commit 6741b7f

Browse files
committed
fix: Reloading driver causes failures on async functions #514
1 parent fc6a995 commit 6741b7f

File tree

1 file changed

+23
-19
lines changed

1 file changed

+23
-19
lines changed

lib/odbc.js

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -304,11 +304,13 @@ function Database(options)
304304
self.mode = options.mode || null;
305305
self.pool = options.pool || null;
306306
if( self.pool ) { // Its a pooled connection
307+
if( !self.realClose ) {
307308
self.realClose = self.close;
308309
self.close = self.poolClose;
309310
self.realCloseSync = self.closeSync;
310311
self.closeSync = self.poolCloseSync;
311-
self.connStr = options.connStr || null;
312+
}
313+
self.connStr = options.connStr || null;
312314
}
313315
} // Database()
314316

@@ -1528,24 +1530,26 @@ Database.prototype.getInfo = function (infoType, infoLen, cb)
15281530
} //getInfo
15291531

15301532
//Proxy all of the ODBCStatement functions so that they are queued
1531-
odbc.ODBCStatement.prototype._execute = odbc.ODBCStatement.prototype.execute;
1532-
odbc.ODBCStatement.prototype._executeSync = odbc.ODBCStatement.prototype.executeSync;
1533-
odbc.ODBCStatement.prototype._executeDirect = odbc.ODBCStatement.prototype.executeDirect;
1534-
odbc.ODBCStatement.prototype._executeDirectSync = odbc.ODBCStatement.prototype.executeDirectSync;
1535-
odbc.ODBCStatement.prototype._executeNonQuery = odbc.ODBCStatement.prototype.executeNonQuery;
1536-
odbc.ODBCStatement.prototype._executeNonQuerySync = odbc.ODBCStatement.prototype.executeNonQuerySync;
1537-
odbc.ODBCStatement.prototype._prepare = odbc.ODBCStatement.prototype.prepare;
1538-
odbc.ODBCStatement.prototype._bind = odbc.ODBCStatement.prototype.bind;
1539-
odbc.ODBCStatement.prototype._bindSync = odbc.ODBCStatement.prototype.bindSync;
1540-
odbc.ODBCStatement.prototype._setAttr = odbc.ODBCStatement.prototype.setAttr;
1541-
odbc.ODBCStatement.prototype._setAttrSync = odbc.ODBCStatement.prototype.setAttrSync;
1542-
odbc.ODBCStatement.prototype._close = odbc.ODBCStatement.prototype.close;
1543-
1544-
//Proxy all of the ODBCResult functions so that they are queued
1545-
odbc.ODBCResult.prototype._fetch = odbc.ODBCResult.prototype.fetch;
1546-
odbc.ODBCResult.prototype._fetchAll = odbc.ODBCResult.prototype.fetchAll;
1547-
odbc.ODBCResult.prototype._getData = odbc.ODBCResult.prototype.getData;
1548-
odbc.ODBCResult.prototype._close = odbc.ODBCResult.prototype.close;
1533+
if( !odbc.ODBCStatement.prototype._execute ) { //issue #514
1534+
odbc.ODBCStatement.prototype._execute = odbc.ODBCStatement.prototype.execute;
1535+
odbc.ODBCStatement.prototype._executeSync = odbc.ODBCStatement.prototype.executeSync;
1536+
odbc.ODBCStatement.prototype._executeDirect = odbc.ODBCStatement.prototype.executeDirect;
1537+
odbc.ODBCStatement.prototype._executeDirectSync = odbc.ODBCStatement.prototype.executeDirectSync;
1538+
odbc.ODBCStatement.prototype._executeNonQuery = odbc.ODBCStatement.prototype.executeNonQuery;
1539+
odbc.ODBCStatement.prototype._executeNonQuerySync = odbc.ODBCStatement.prototype.executeNonQuerySync;
1540+
odbc.ODBCStatement.prototype._prepare = odbc.ODBCStatement.prototype.prepare;
1541+
odbc.ODBCStatement.prototype._bind = odbc.ODBCStatement.prototype.bind;
1542+
odbc.ODBCStatement.prototype._bindSync = odbc.ODBCStatement.prototype.bindSync;
1543+
odbc.ODBCStatement.prototype._setAttr = odbc.ODBCStatement.prototype.setAttr;
1544+
odbc.ODBCStatement.prototype._setAttrSync = odbc.ODBCStatement.prototype.setAttrSync;
1545+
odbc.ODBCStatement.prototype._close = odbc.ODBCStatement.prototype.close;
1546+
1547+
//Proxy all of the ODBCResult functions so that they are queued
1548+
odbc.ODBCResult.prototype._fetch = odbc.ODBCResult.prototype.fetch;
1549+
odbc.ODBCResult.prototype._fetchAll = odbc.ODBCResult.prototype.fetchAll;
1550+
odbc.ODBCResult.prototype._getData = odbc.ODBCResult.prototype.getData;
1551+
odbc.ODBCResult.prototype._close = odbc.ODBCResult.prototype.close;
1552+
}
15491553

15501554
odbc.ODBCStatement.prototype.execute = function (params, cb)
15511555
{

0 commit comments

Comments
 (0)