diff options
author | Nicholas Seckar <nseckar@gmail.com> | 2005-09-29 11:16:51 +0000 |
---|---|---|
committer | Nicholas Seckar <nseckar@gmail.com> | 2005-09-29 11:16:51 +0000 |
commit | 6f3804113329d407d134c235120ab2e1e8da5244 (patch) | |
tree | fce060cf9e4b4cbe226a1526de684c66998fd153 /activerecord/lib/active_record | |
parent | 438db964ad1531d3c378c3e4acc25d0007cbc1cc (diff) | |
download | rails-6f3804113329d407d134c235120ab2e1e8da5244.tar.gz rails-6f3804113329d407d134c235120ab2e1e8da5244.tar.bz2 rails-6f3804113329d407d134c235120ab2e1e8da5244.zip |
Fix broken testcase for transactions
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2409 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb b/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb index febc702922..d99b2c84e4 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb @@ -39,20 +39,24 @@ module ActiveRecord # Wrap a block in a transaction. Returns result of block. def transaction(start_db_transaction = true) - needs_commit = false + transaction_open = false begin if block_given? - begin_db_transaction if start_db_transaction - needs_commit = start_db_transaction + if start_db_transaction + begin_db_transaction + transaction_open = true + end yield end rescue Exception => database_transaction_rollback - rollback_db_transaction if start_db_transaction - needs_commit = false + if transaction_open + transaction_open = false + rollback_db_transaction + end raise end ensure - commit_db_transaction if needs_commit + commit_db_transaction if transaction_open end # Begins the transaction (and turns off auto-committing). |