diff options
author | Jon Leighton <j@jonathanleighton.com> | 2012-09-14 17:44:34 +0100 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2012-09-15 00:00:50 +0100 |
commit | 58ced308d77c2526a65d7526cad01a2d75145542 (patch) | |
tree | da24b05a8a26304feb5ac797afa54b963287859e /activerecord/lib/active_record/connection_adapters | |
parent | 9296e6939bcc786149a07dac334267c4035b623a (diff) | |
download | rails-58ced308d77c2526a65d7526cad01a2d75145542.tar.gz rails-58ced308d77c2526a65d7526cad01a2d75145542.tar.bz2 rails-58ced308d77c2526a65d7526cad01a2d75145542.zip |
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)
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb | 2 | ||||
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/transaction.rb | 23 |
2 files changed, 7 insertions, 18 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb b/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb index 5eb0f0f132..4cbc6a5035 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb @@ -203,7 +203,7 @@ module ActiveRecord begin @transaction = @transaction.commit rescue Exception - @transaction = @transaction.parent + @transaction = @transaction.rollback raise end end diff --git a/activerecord/lib/active_record/connection_adapters/abstract/transaction.rb b/activerecord/lib/active_record/connection_adapters/abstract/transaction.rb index 4f1f9223ec..7f82b8f666 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/transaction.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/transaction.rb @@ -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 |