mirror of https://github.com/rails/rails
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:
parent
9296e6939b
commit
58ced308d7
|
@ -203,7 +203,7 @@ module ActiveRecord
|
|||
begin
|
||||
@transaction = @transaction.commit
|
||||
rescue Exception
|
||||
@transaction = @transaction.parent
|
||||
@transaction = @transaction.rollback
|
||||
raise
|
||||
end
|
||||
end
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue