Skip to content

Commit

Permalink
Reset the open transaction count on Connection#reset.
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurschreiber committed Jan 23, 2015
1 parent e437b0f commit 824bac1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/connection.coffee
Expand Up @@ -847,7 +847,8 @@ set xact_abort #{xact_abort}"""
true

reset: (callback) =>
request = new Request(@getInitialSql(), (err, rowCount, rows) ->
request = new Request(@getInitialSql(), (err, rowCount, rows) =>
@openTransactions = 0 unless err
callback(err)
)

Expand Down
18 changes: 18 additions & 0 deletions test/integration/transactions-test.coffee
Expand Up @@ -318,3 +318,21 @@ exports.transactionHelperFullRollback = (test) ->
connection.execSql(request)
connection.execSql(request)
connection.execSqlBatch(request)

exports.transactionHelperResetOpenTransactionCount = (test) ->
test.expect(3)

connection = new Connection(config)
connection.on('end', (info) => test.done())
connection.on('errorMessage', (error) => console.log("#{error.number} : #{error.message}"))
connection.on('debug', (message) => console.log(message) if (debug))

connection.on 'connect', (err) ->
connection.transaction (err) ->
test.ifError(err)

connection.reset (err) ->
test.ifError(err)

test.strictEqual(connection.openTransactions, 0)
connection.close()

0 comments on commit 824bac1

Please sign in to comment.