diff options
Diffstat (limited to 'activerecord/lib/active_record')
-rwxr-xr-x | activerecord/lib/active_record/base.rb | 2 | ||||
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb | 11 |
2 files changed, 5 insertions, 8 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index bb3c58067d..31b25e5979 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -34,6 +34,8 @@ module ActiveRecord #:nodoc: end class ReadOnlyRecord < StandardError #:nodoc: end + class Rollback < StandardError #:nodoc: + end class AttributeAssignmentError < ActiveRecordError #:nodoc: attr_reader :exception, :attribute 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 1b75ab53fe..bc59f064aa 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb @@ -56,14 +56,14 @@ module ActiveRecord begin_db_transaction transaction_open = true end - yield self - end + yield + end rescue Exception => database_transaction_rollback if transaction_open transaction_open = false rollback_db_transaction end - raise + raise unless database_transaction_rollback.is_a? ActiveRecord::Rollback end ensure commit_db_transaction if transaction_open @@ -79,11 +79,6 @@ module ActiveRecord # done if the transaction block raises an exception or returns false. def rollback_db_transaction() end - # Alias for rollback_db_transaction to be used when yielding the transaction - def rollback! - rollback_db_transaction - end - # Alias for #add_limit_offset!. def add_limit!(sql, options) add_limit_offset!(sql, options) if options |