aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2019-04-10 19:26:15 +0900
committerRyuta Kamizono <kamipo@gmail.com>2019-04-10 19:26:15 +0900
commitbcb0fb792735e1be08ccffb153654cfc886e5ff4 (patch)
treeddd3b03baac97a33e2a8ad320d4b9aad1c5574af /activerecord/lib
parent5f261d04d6f857d49c75124df809adfbd6cd5b5e (diff)
downloadrails-bcb0fb792735e1be08ccffb153654cfc886e5ff4.tar.gz
rails-bcb0fb792735e1be08ccffb153654cfc886e5ff4.tar.bz2
rails-bcb0fb792735e1be08ccffb153654cfc886e5ff4.zip
Lazy sync with transaction state on destroy
This reverts commit 58410b3d566e6b93c7b71c0eec0fc11ec906b68e. If we have any implicit commit/rollback callbacks, it is necessary to add record to transaction explicitly like `:touch_deferred_attributes`. https://github.com/rails/rails/blob/5f261d04d6f857d49c75124df809adfbd6cd5b5e/activerecord/lib/active_record/touch_later.rb#L9 https://github.com/rails/rails/blob/5f261d04d6f857d49c75124df809adfbd6cd5b5e/activerecord/lib/active_record/touch_later.rb#L25 But I can't find any other implicit commit/rollback callbacks in our code base at least now. I think the `self.class.connection.add_transaction_record(self)` line doesn't cover any behavior.
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/core.rb3
-rw-r--r--activerecord/lib/active_record/persistence.rb1
2 files changed, 2 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/core.rb b/activerecord/lib/active_record/core.rb
index eb4b48bc37..6fed3e5c19 100644
--- a/activerecord/lib/active_record/core.rb
+++ b/activerecord/lib/active_record/core.rb
@@ -466,6 +466,7 @@ module ActiveRecord
# Returns +true+ if the attributes hash has been frozen.
def frozen?
+ sync_with_transaction_state
@attributes.frozen?
end
@@ -583,7 +584,7 @@ module ActiveRecord
end
def thaw
- if frozen?
+ if @attributes.frozen?
@attributes = @attributes.dup
end
end
diff --git a/activerecord/lib/active_record/persistence.rb b/activerecord/lib/active_record/persistence.rb
index e05490753f..bc6d04b7bb 100644
--- a/activerecord/lib/active_record/persistence.rb
+++ b/activerecord/lib/active_record/persistence.rb
@@ -530,7 +530,6 @@ module ActiveRecord
def destroy
_raise_readonly_record_error if readonly?
destroy_associations
- self.class.connection.add_transaction_record(self)
@_trigger_destroy_callback = if persisted?
destroy_row > 0
else