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)
This commit is contained in:
Jon Leighton 2012-09-14 17:44:34 +01:00
parent 9296e6939b
commit 58ced308d7
2 changed files with 7 additions and 18 deletions

View File

@ -203,7 +203,7 @@ module ActiveRecord
begin
@transaction = @transaction.commit
rescue Exception
@transaction = @transaction.parent
@transaction = @transaction.rollback
raise
end
end

View File

@ -84,23 +84,12 @@ module ActiveRecord
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