diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2008-09-04 13:17:00 +0200 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2008-09-04 13:17:00 +0200 |
commit | 039d78a7d81c8ac49dcb6ba0304d32af671d56c9 (patch) | |
tree | 7ca0655bc43139260ca14adca1e1fd2bbfa82e5f /activerecord | |
parent | 045713ee240fff815edb5962b25d668512649478 (diff) | |
download | rails-039d78a7d81c8ac49dcb6ba0304d32af671d56c9.tar.gz rails-039d78a7d81c8ac49dcb6ba0304d32af671d56c9.tar.bz2 rails-039d78a7d81c8ac49dcb6ba0304d32af671d56c9.zip |
still need to track whether we're the toplevel transaction
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb index e95db1d9d8..bebab5d05d 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb @@ -529,17 +529,24 @@ module ActiveRecord # Wrap a block in a transaction. Returns result of block. def transaction(start_db_transaction = true) + transaction_open = false begin if block_given? - begin_db_transaction if 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 transaction_active? + if transaction_open && transaction_active? + transaction_open = false + rollback_db_transaction + end raise unless database_transaction_rollback.is_a? ActiveRecord::Rollback end ensure - if transaction_active? + if transaction_open && transaction_active? begin commit_db_transaction rescue Exception => database_transaction_rollback |