Skip to content

Commit 450ade7

Browse files
committed
[rails#52698] Fix comparison of Timestamp value for PostgreSQL.
1 parent a59ddc7 commit 450ade7

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

activerecord/lib/active_record/connection_adapters/postgresql/oid/timestamp.rb

+7
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ class Timestamp < DateTime # :nodoc:
88
def type
99
real_type_unless_aliased(:timestamp)
1010
end
11+
12+
def ==(other)
13+
precision == other.precision &&
14+
scale == other.scale &&
15+
limit == other.limit &&
16+
type == other.type
17+
end
1118
end
1219
end
1320
end

activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb

+9
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,15 @@ def test_disable_extension_without_schema
715715
@connection.execute("DROP EXTENSION IF EXISTS hstore")
716716
end
717717

718+
def test_time_zone_converter_equals_to_timestamp
719+
subtype = ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Timestamp.new
720+
value = ActiveRecord::AttributeMethods::TimeZoneConversion::TimeZoneConverter.new(subtype)
721+
722+
value_from_cache = Marshal.load(Marshal.dump(value))
723+
724+
assert_equal value, value_from_cache
725+
end
726+
718727
private
719728
def with_postgresql_apdater_decode_dates
720729
PostgreSQLAdapter.decode_dates = true

0 commit comments

Comments
 (0)