Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Reverts "Fix bugs with changed attributes tracking when transaction g…

…ets rollback"

We are reverting these commits, because there are other caveats related
to dirty attributes not being restored when a transaction is rollback.
For instance, nested transactions cannot proper restore the dirty
attributes state after a rollback.

At the moment, the dirty attributes are scoped by the transaction.
When we call `.save` on a record, the dirty attributes will be reset even
if the transaction gets rollback.

[related #13166]
[related #15018]
[related #15016]
[closes #15019]

This reverts commits
* bab48f0
  * b0fa7cf.
* 73fb39b
  * 37c2389.
  * 8d8d4f1

Revert "Merge pull request #13166 from bogdan/transaction-magic"
  • Loading branch information...
commit 198d9e3dfb943c309520e98b86d48c113eb5acbb 1 parent 0a7beb1
@arthurnn arthurnn authored
View
6 activerecord/CHANGELOG.md
@@ -12,12 +12,6 @@
*Paul B.*
-* Keep track of dirty attributes after transaction is rollback.
-
- Related #13166.
-
- *Bogdan Gusiev* *arthurnn*
-
* Add support for module-level `table_name_suffix` in models.
This makes `table_name_suffix` work the same way as `table_name_prefix` when
View
4 activerecord/lib/active_record/transactions.rb
@@ -350,7 +350,6 @@ def remember_transaction_record_state #:nodoc:
end
@_start_transaction_state[:level] = (@_start_transaction_state[:level] || 0) + 1
@_start_transaction_state[:frozen?] = @attributes.frozen?
- @_start_transaction_state[:changed_attributes] ||= changed_attributes.dup
end
# Clear the new record state and id of a record.
@@ -369,9 +368,6 @@ def restore_transaction_record_state(force = false) #:nodoc:
@attributes = @attributes.dup if @attributes.frozen?
@new_record = restore_state[:new_record]
@destroyed = restore_state[:destroyed]
- changed_attributes.replace(restore_state[:changed_attributes]).delete_if do |attribute, old_value|
- old_value == @attributes[attribute]
- end
if restore_state.has_key?(:id)
write_attribute(self.class.primary_key, restore_state[:id])
else
View
42 activerecord/test/cases/transactions_test.rb
@@ -274,48 +274,6 @@ def test_invalid_keys_for_transaction
end
end
- def test_rollback_when_changing_inside_transaction
- assert !@first.approved?
- Topic.transaction do
- @first.approved = true
- @first.save!
- raise ActiveRecord::Rollback
- end
- assert @first.approved
- assert @first.changes["approved"]
- @first.save!
- assert @first.reload.approved
- end
-
- def test_rollback_when_changing_outside_transaction
- assert !@first.approved?
- @first.approved = true
- Topic.transaction do
- @first.save!
- raise ActiveRecord::Rollback
- end
- assert @first.changes["approved"]
- assert @first.approved
- @first.save!
- assert @first.reload.approved
- end
-
- def test_rollback_when_changing_back_to_prev_stage
- assert !@first.approved?
- Topic.transaction do
- @first.approved = true
- @first.save!
- @first.approved = false
- @first.save!
- raise ActiveRecord::Rollback
- end
- assert !@first.approved
- assert !@first.changes["approved"]
- @first.save!
- assert !@first.reload.approved
- end
-
-
def test_force_savepoint_in_nested_transaction
Topic.transaction do
@first.approved = true
Please sign in to comment.
Something went wrong with that request. Please try again.