From 44819b47179936492c093811ed0f625ce6e029a3 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Wed, 22 Dec 2004 00:48:24 +0000 Subject: Fixed that nested transactions now work by letting the outer most transaction have the responsibilty of starting and rolling back the transaction. If any of the inner transactions swallow the exception raised, though, the transaction will not be rolled back. So always let the transaction bubble up even when you've dealt with local issues. Closes #231 and #340. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@242 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- .../lib/active_record/connection_adapters/abstract_adapter.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'activerecord/lib/active_record/connection_adapters/abstract_adapter.rb') diff --git a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb index b521a0fdf8..d41356ffa4 100755 --- a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb @@ -298,16 +298,16 @@ module ActiveRecord end # Wrap a block in a transaction. Returns result of block. - def transaction + def transaction(start_db_transaction = true) begin if block_given? - begin_db_transaction + begin_db_transaction if start_db_transaction result = yield - commit_db_transaction + commit_db_transaction if start_db_transaction result end rescue Exception => database_transaction_rollback - rollback_db_transaction + rollback_db_transaction if start_db_transaction raise end end -- cgit v1.2.3