mirror of https://github.com/rails/rails
Merge pull request #51713 from Shopify/stale-state-casting
Don't cast `stale_state` to String
This commit is contained in:
commit
087260d0fc
|
@ -148,8 +148,7 @@ module ActiveRecord
|
|||
end
|
||||
|
||||
def stale_state
|
||||
result = owner._read_attribute(reflection.foreign_key) { |n| owner.send(:missing_attribute, n, caller) }
|
||||
result && result.to_s
|
||||
owner._read_attribute(reflection.foreign_key) { |n| owner.send(:missing_attribute, n, caller) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -41,8 +41,9 @@ module ActiveRecord
|
|||
end
|
||||
|
||||
def stale_state
|
||||
foreign_key = super
|
||||
foreign_key && [foreign_key.to_s, owner[reflection.foreign_type].to_s]
|
||||
if foreign_key = super
|
||||
[foreign_key, owner[reflection.foreign_type]]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -82,7 +82,7 @@ module ActiveRecord
|
|||
def stale_state
|
||||
if through_reflection.belongs_to?
|
||||
Array(through_reflection.foreign_key).filter_map do |foreign_key_column|
|
||||
owner[foreign_key_column] && owner[foreign_key_column].to_s
|
||||
owner[foreign_key_column]
|
||||
end.presence
|
||||
end
|
||||
end
|
||||
|
|
|
@ -33,7 +33,6 @@ class MarshalSerializationTest < ActiveRecord::TestCase
|
|||
assert_equal "Have a nice day", topic.content
|
||||
assert_predicate topic.association(:replies), :loaded?
|
||||
assert_predicate topic.replies.first.association(:topic), :loaded?
|
||||
assert_same topic, topic.replies.first.topic
|
||||
end
|
||||
|
||||
def test_deserializing_rails_7_1_marshal_basic
|
||||
|
|
Loading…
Reference in New Issue