Skip to content
Browse files

Don't do the rollback in #commit

The caller needs to have knowledge of the rollback either way, so do it
all in the caller (#transaction)
  • Loading branch information...
1 parent 9296e69 commit 58ced308d77c2526a65d7526cad01a2d75145542 @jonleighton jonleighton committed Sep 14, 2012
View
2 activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb
@@ -203,7 +203,7 @@ def transaction(options = {})
begin
@transaction = @transaction.commit
rescue Exception
- @transaction = @transaction.parent
+ @transaction = @transaction.rollback
raise
end
end
View
23 activerecord/lib/active_record/connection_adapters/abstract/transaction.rb
@@ -84,23 +84,12 @@ def rollback
def commit
@finishing = true
- begin
- if parent.open?
- connection.release_savepoint
- records.each { |r| parent.add_record(r) }
- else
- connection.commit_db_transaction
- commit_records
- end
- rescue Exception
- if parent.open?
- connection.rollback_to_savepoint
- else
- connection.rollback_db_transaction
- end
-
- rollback_records
- raise
+ if parent.open?
+ connection.release_savepoint
+ records.each { |r| parent.add_record(r) }
+ else
+ connection.commit_db_transaction
+ commit_records
end
parent

0 comments on commit 58ced30

Please sign in to comment.
Something went wrong with that request. Please try again.