Skip to content

Commit c226593

Browse files
ruyrocharafaelfranca
authored andcommitted
[rails#52699] Update TimeZoneConverter#== method to make it symmetric, so it can...
properly compare `other` with `itself`, and remove the comparison of type, scale, limit & precision.
1 parent f0fd6ab commit c226593

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,7 @@ def cast(value)
3333
end
3434

3535
def ==(other)
36-
precision == other.precision &&
37-
scale == other.scale &&
38-
limit == other.limit &&
39-
type == other.type
36+
other.is_a?(self.class) && __getobj__ == other.__getobj__
4037
end
4138

4239
private

activerecord/test/cases/attribute_methods/time_zone_converter_test.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ def test_comparison_with_date_time_type
1313
value_from_cache = Marshal.load(Marshal.dump(value))
1414

1515
assert_equal value, value_from_cache
16+
assert_not_equal value, "foo"
1617
end
1718
end
1819
end

0 commit comments

Comments
 (0)