Skip to content
Browse files

Revert "Wrap calls to update_attributes in a transaction."

This caused failures on sqlite, sqlite3 and postgresql

This reverts commit fc09ebc.
[#922 state:reopened]
  • Loading branch information...
1 parent 3248553 commit 06040849b5a680c2a87893699580f9b9b80f72e4 @NZKoz NZKoz committed Feb 22, 2009
Showing with 1 addition and 49 deletions.
  1. +1 −15 activerecord/lib/active_record/transactions.rb
  2. +0 −34 activerecord/test/cases/transactions_test.rb
View
16 activerecord/lib/active_record/transactions.rb
@@ -10,7 +10,7 @@ def self.included(base)
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 @@ def save_with_transactions! #:nodoc:
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)
View
34 activerecord/test/cases/transactions_test.rb
@@ -182,40 +182,6 @@ def test_callback_rollback_in_create
end
end
- def test_update_attribute_should_rollback_on_failure
- Developer.before_save do
- false
- end
- developer = Developer.first
- developer.audit_logs.clear
- 2.times { developer.audit_logs.create(:message => 'message') }
- assert_equal 2, developer.audit_logs.size
- status = developer.update_attribute(:audit_log_ids, [])
- assert !status
- assert_equal 2, developer.audit_logs(true).size
- end
-
- def test_update_attributes_should_rollback_on_failure
- developer = Developer.first
- developer.audit_logs.clear
- 2.times { developer.audit_logs.create(:message => 'message') }
- assert_equal 2, developer.audit_logs.size
- status = developer.update_attributes(:audit_log_ids => [], :name => nil)
- assert !status
- assert_equal 2, developer.audit_logs(true).size
- end
-
- def test_update_attributes_should_rollback_on_failure!
- developer = Developer.first
- developer.audit_logs.clear
- 2.times { developer.audit_logs.create(:message => 'message') }
- assert_equal 2, developer.audit_logs.size
- assert_raise(ActiveRecord::RecordInvalid) do
- developer.update_attributes!(:audit_log_ids => [], :name => nil)
- end
- assert_equal 2, developer.audit_logs(true).size
- end
-
def test_nested_explicit_transactions
Topic.transaction do
Topic.transaction do

0 comments on commit 0604084

Please sign in to comment.
Something went wrong with that request. Please try again.