2014-09-01 17:18:45 +02:00
|
|
|
|
2015-04-19 16:31:52 -04:00
|
|
|
function finishOracleTransaction(connection, finishFunc) {
|
|
|
|
return new Promise(function (resolver, rejecter) {
|
|
|
|
return finishFunc.bind(connection)(function (err, result) {
|
|
|
|
if (err) {
|
|
|
|
return rejecter(err);
|
|
|
|
}
|
|
|
|
// reset AutoCommit back to default to allow recycling in pool
|
|
|
|
connection.setAutoCommit(true);
|
|
|
|
resolver(result);
|
|
|
|
});
|
|
|
|
});
|
2014-08-11 12:25:39 +02:00
|
|
|
}
|
|
|
|
|
2015-04-19 16:31:52 -04:00
|
|
|
// disable autocommit to allow correct behavior (default is true)
|
|
|
|
Runner_Oracle.prototype.beginTransaction = function() {
|
|
|
|
return this.connection.setAutoCommit(false);
|
|
|
|
};
|
|
|
|
Runner_Oracle.prototype.commitTransaction = function() {
|
|
|
|
return finishOracleTransaction(this.connection, this.connection.commit);
|
|
|
|
};
|
|
|
|
Runner_Oracle.prototype.rollbackTransaction = function() {
|
|
|
|
return finishOracleTransaction(this.connection, this.connection.rollback);
|
2014-08-11 12:25:39 +02:00
|
|
|
};
|