aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorSean Griffin <sean@seantheprogrammer.com>2018-03-06 15:07:24 -0700
committerSean Griffin <sean@seantheprogrammer.com>2018-03-06 15:11:22 -0700
commit5fcbdcfb574c731841be12764c50d9587b58345f (patch)
tree24f35f373401f208c10dced469662f763b61c743 /activerecord
parent0b717c20458d12191f479fc693dd1ca1eb11c050 (diff)
downloadrails-5fcbdcfb574c731841be12764c50d9587b58345f.tar.gz
rails-5fcbdcfb574c731841be12764c50d9587b58345f.tar.bz2
rails-5fcbdcfb574c731841be12764c50d9587b58345f.zip
Revert "PERF: Recover `changes_applied` performance (#31698)"
This reverts commit a19e91f0fab13cca61acdb1f33e27be2323b9786.
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/attribute_methods/dirty.rb6
-rw-r--r--activerecord/lib/active_record/persistence.rb1
2 files changed, 5 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/attribute_methods/dirty.rb b/activerecord/lib/active_record/attribute_methods/dirty.rb
index df4c79b0f6..3de6fe566d 100644
--- a/activerecord/lib/active_record/attribute_methods/dirty.rb
+++ b/activerecord/lib/active_record/attribute_methods/dirty.rb
@@ -32,7 +32,9 @@ module ActiveRecord
# <tt>reload</tt> the record and clears changed attributes.
def reload(*)
super.tap do
+ @previously_changed = ActiveSupport::HashWithIndifferentAccess.new
@mutations_before_last_save = nil
+ @attributes_changed_by_setter = ActiveSupport::HashWithIndifferentAccess.new
@mutations_from_database = nil
end
end
@@ -112,12 +114,12 @@ module ActiveRecord
# Alias for +changed+
def changed_attribute_names_to_save
- mutations_from_database.changed_attribute_names
+ changes_to_save.keys
end
# Alias for +changed_attributes+
def attributes_in_database
- mutations_from_database.changed_values
+ changes_to_save.transform_values(&:first)
end
private
diff --git a/activerecord/lib/active_record/persistence.rb b/activerecord/lib/active_record/persistence.rb
index d4f4a5887a..6ec477c7f3 100644
--- a/activerecord/lib/active_record/persistence.rb
+++ b/activerecord/lib/active_record/persistence.rb
@@ -374,6 +374,7 @@ module ActiveRecord
became.send(:initialize)
became.instance_variable_set("@attributes", @attributes)
became.instance_variable_set("@mutations_from_database", @mutations_from_database) if defined?(@mutations_from_database)
+ became.instance_variable_set("@changed_attributes", attributes_changed_by_setter)
became.instance_variable_set("@new_record", new_record?)
became.instance_variable_set("@destroyed", destroyed?)
became.errors.copy!(errors)