Skip to content

Commit 364dfaa

Browse files
committed
Use pg callback over connection.release (#109)
1 parent af9a265 commit 364dfaa

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/transaction.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ function mixinTransaction(PostgreSQL) {
2121
debug('Begin a transaction with isolation level: %s', isolationLevel);
2222
this.pg.connect(function(err, connection, done) {
2323
if (err) return cb(err);
24+
connection.autorelease = done;
2425
connection.query('BEGIN TRANSACTION ISOLATION LEVEL ' + isolationLevel,
2526
function(err) {
2627
if (err) return cb(err);
@@ -63,9 +64,9 @@ function mixinTransaction(PostgreSQL) {
6364
};
6465

6566
PostgreSQL.prototype.releaseConnection = function(connection, err) {
66-
if (typeof connection.release === 'function') {
67-
connection.release(err);
68-
connection.release = null;
67+
if (typeof connection.autorelease === 'function') {
68+
connection.autorelease(err);
69+
connection.autorelease = null;
6970
} else {
7071
var pool = this.pg;
7172
if (err) {

0 commit comments

Comments
 (0)