diff options
author | Sean Griffin <sean@thoughtbot.com> | 2014-12-08 14:49:46 -0700 |
---|---|---|
committer | Sean Griffin <sean@thoughtbot.com> | 2014-12-08 14:52:06 -0700 |
commit | 42418cfc94d1356d35d28d786f63e7fab9406ad6 (patch) | |
tree | e53ab56d92456a6a97bc5a8799490baba27d6430 /activerecord/test | |
parent | 7daeb98c769a3968a2ccf48ff593909bf1a9d7b0 (diff) | |
download | rails-42418cfc94d1356d35d28d786f63e7fab9406ad6.tar.gz rails-42418cfc94d1356d35d28d786f63e7fab9406ad6.tar.bz2 rails-42418cfc94d1356d35d28d786f63e7fab9406ad6.zip |
Allow custom handling of non-standard types in `time_zone_conversion`
PostgreSQL for example, allows infinity as a valid value for date time
columns. The PG type has explicit handling for that case. However, time
zone conversion will end up trampling that handling. Unfortunately, we
can't call super and then convert time zones.
However, if we get back nil from `.in_time_zone`, it's something we
didn't expect so we can let the superclass handle it.
Fixes #17971
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/adapters/postgresql/infinity_test.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/activerecord/test/cases/adapters/postgresql/infinity_test.rb b/activerecord/test/cases/adapters/postgresql/infinity_test.rb index 22e8873333..30404cd181 100644 --- a/activerecord/test/cases/adapters/postgresql/infinity_test.rb +++ b/activerecord/test/cases/adapters/postgresql/infinity_test.rb @@ -41,4 +41,10 @@ class PostgresqlInfinityTest < ActiveRecord::TestCase record.reload assert_equal Float::INFINITY, record.datetime end + + test "assigning 'infinity' on a datetime column" do + record = PostgresqlInfinity.create!(datetime: "infinity") + assert_equal Float::INFINITY, record.datetime + assert_equal record.datetime, record.reload.datetime + end end |