Skip to content

Commit 96ea772

Browse files
authored
Merge pull request rails#53507 from Shopify/clear-timestamps
Optimize AR::Timestamp#clear_timestamp_attributes
2 parents 07ce474 + 46efabd commit 96ea772

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

activerecord/lib/active_record/timestamp.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,10 @@ def max_updated_column_timestamp
169169
# Clear attributes and changed_attributes
170170
def clear_timestamp_attributes
171171
all_timestamp_attributes_in_model.each do |attribute_name|
172-
self[attribute_name] = nil
173-
clear_attribute_change(attribute_name)
172+
if self[attribute_name]
173+
self[attribute_name] = nil
174+
clear_attribute_change(attribute_name)
175+
end
174176
end
175177
end
176178
end

0 commit comments

Comments
 (0)