Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

still need to track whether we're the toplevel transaction

  • Loading branch information...
commit 039d78a7d81c8ac49dcb6ba0304d32af671d56c9 1 parent 045713e
@jeremy jeremy authored
View
13 activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
@@ -529,17 +529,24 @@ def transaction_active?
# 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
Please sign in to comment.
Something went wrong with that request. Please try again.