diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2007-06-23 00:54:51 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2007-06-23 00:54:51 +0000 |
commit | c627590fd405bab67fce498cd2b6a781f99f261b (patch) | |
tree | 28c055d9ef6728fc91de10e1849ac97cc0501625 /activerecord/lib/active_record | |
parent | 40f6e9f8e126c494ff89b4c149bbd7a1fe7df197 (diff) | |
download | rails-c627590fd405bab67fce498cd2b6a781f99f261b.tar.gz rails-c627590fd405bab67fce498cd2b6a781f99f261b.tar.bz2 rails-c627590fd405bab67fce498cd2b6a781f99f261b.zip |
Rollback if commit raises an exception. Closes #8642.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7088 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 | 11 |
1 files changed, 9 insertions, 2 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 3b35a190f9..943aed98d8 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb @@ -57,7 +57,7 @@ module ActiveRecord transaction_open = true end yield - end + end rescue Exception => database_transaction_rollback if transaction_open transaction_open = false @@ -66,7 +66,14 @@ module ActiveRecord raise unless database_transaction_rollback.is_a? ActiveRecord::Rollback end ensure - commit_db_transaction if transaction_open + if transaction_open + begin + commit_db_transaction + rescue Exception => database_transaction_rollback + rollback_db_transaction + raise + end + end end # Begins the transaction (and turns off auto-committing). |