aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2004-12-22 00:48:24 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2004-12-22 00:48:24 +0000
commit44819b47179936492c093811ed0f625ce6e029a3 (patch)
treef6653b9e9a9c8fd41dab1cc40f78e4e4d565b65c /activerecord/lib/active_record/connection_adapters
parent58f2bd0cfc1713ee3ed519d6b75bbfa386c131c3 (diff)
downloadrails-44819b47179936492c093811ed0f625ce6e029a3.tar.gz
rails-44819b47179936492c093811ed0f625ce6e029a3.tar.bz2
rails-44819b47179936492c093811ed0f625ce6e029a3.zip
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
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters')
-rwxr-xr-xactiverecord/lib/active_record/connection_adapters/abstract_adapter.rb8
1 files changed, 4 insertions, 4 deletions
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