mirror of
https://github.com/knex/knex.git
synced 2025-07-28 03:13:15 +00:00
25 lines
826 B
JavaScript
25 lines
826 B
JavaScript
|
|
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);
|
|
});
|
|
});
|
|
}
|
|
|
|
// 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);
|
|
};
|