From fc09ebc669bd58f415f7d3ef932ef02dab821ab5 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Sun, 1 Feb 2009 11:13:27 +0100 Subject: Wrap calls to update_attributes in a transaction. Signed-off-by: Michael Koziarski [#922 state:committed] --- activerecord/lib/active_record/transactions.rb | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'activerecord/lib/active_record/transactions.rb') diff --git a/activerecord/lib/active_record/transactions.rb b/activerecord/lib/active_record/transactions.rb index 0b6e52c79b..9eabe7172b 100644 --- a/activerecord/lib/active_record/transactions.rb +++ b/activerecord/lib/active_record/transactions.rb @@ -10,7 +10,7 @@ module ActiveRecord base.extend(ClassMethods) base.class_eval do - [:destroy, :save, :save!].each do |method| + [:destroy, :save, :save!, :update_attribute, :update_attributes, :update_attributes!].each do |method| alias_method_chain method, :transactions end end @@ -200,6 +200,20 @@ module ActiveRecord rollback_active_record_state! { self.class.transaction { save_without_transactions! } } end + def update_attribute_with_transactions(name, value) + with_transaction_returning_status(:update_attribute_without_transactions, name, value) + end + + def update_attributes_with_transactions(attributes) + with_transaction_returning_status(:update_attributes_without_transactions, attributes) + end + + def update_attributes_with_transactions!(attributes) + transaction do + update_attributes_without_transactions!(attributes) + end + end + # Reset id and @new_record if the transaction rolls back. def rollback_active_record_state! id_present = has_attribute?(self.class.primary_key) -- cgit v1.2.3 From 06040849b5a680c2a87893699580f9b9b80f72e4 Mon Sep 17 00:00:00 2001 From: Michael Koziarski Date: Sun, 22 Feb 2009 16:26:32 +1300 Subject: Revert "Wrap calls to update_attributes in a transaction." This caused failures on sqlite, sqlite3 and postgresql This reverts commit fc09ebc669bd58f415f7d3ef932ef02dab821ab5. [#922 state:reopened] --- activerecord/lib/active_record/transactions.rb | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) (limited to 'activerecord/lib/active_record/transactions.rb') diff --git a/activerecord/lib/active_record/transactions.rb b/activerecord/lib/active_record/transactions.rb index 9eabe7172b..0b6e52c79b 100644 --- a/activerecord/lib/active_record/transactions.rb +++ b/activerecord/lib/active_record/transactions.rb @@ -10,7 +10,7 @@ module ActiveRecord base.extend(ClassMethods) base.class_eval do - [:destroy, :save, :save!, :update_attribute, :update_attributes, :update_attributes!].each do |method| + [:destroy, :save, :save!].each do |method| alias_method_chain method, :transactions end end @@ -200,20 +200,6 @@ module ActiveRecord rollback_active_record_state! { self.class.transaction { save_without_transactions! } } end - def update_attribute_with_transactions(name, value) - with_transaction_returning_status(:update_attribute_without_transactions, name, value) - end - - def update_attributes_with_transactions(attributes) - with_transaction_returning_status(:update_attributes_without_transactions, attributes) - end - - def update_attributes_with_transactions!(attributes) - transaction do - update_attributes_without_transactions!(attributes) - end - end - # Reset id and @new_record if the transaction rolls back. def rollback_active_record_state! id_present = has_attribute?(self.class.primary_key) -- cgit v1.2.3 From 632bbbfe1cc49ab92c6de858865ffcdcfa67635f Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Sat, 4 Apr 2009 17:33:36 +0100 Subject: Merge docrails --- activerecord/lib/active_record/transactions.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'activerecord/lib/active_record/transactions.rb') diff --git a/activerecord/lib/active_record/transactions.rb b/activerecord/lib/active_record/transactions.rb index 0b6e52c79b..b059eb7f6f 100644 --- a/activerecord/lib/active_record/transactions.rb +++ b/activerecord/lib/active_record/transactions.rb @@ -175,6 +175,8 @@ module ActiveRecord # end # RELEASE savepoint active_record_1 # # ^^^^ BOOM! database error! # end + # + # Note that "TRUNCATE" is also a MySQL DDL statement! module ClassMethods # See ActiveRecord::Transactions::ClassMethods for detailed documentation. def transaction(options = {}, &block) -- cgit v1.2.3