aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorSean Griffin <sean@seantheprogrammer.com>2015-09-23 09:01:38 -0600
committerSean Griffin <sean@seantheprogrammer.com>2015-09-23 09:01:38 -0600
commit66337b62ad5fe8004394608584baff137f4cc93e (patch)
tree184c61660e43fa78f2013f0910120d300a758fe5 /activerecord/lib
parentf5fe01e8366ae393aca93635a8f04d4ed3f7cdd7 (diff)
parentd03f5196657bf466d7576cd6cbd4886db030723b (diff)
downloadrails-66337b62ad5fe8004394608584baff137f4cc93e.tar.gz
rails-66337b62ad5fe8004394608584baff137f4cc93e.tar.bz2
rails-66337b62ad5fe8004394608584baff137f4cc93e.zip
Merge pull request #20317
AR: take precision into count when assigning a value to timestamp attribute
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql/oid/date_time.rb18
1 files changed, 7 insertions, 11 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/oid/date_time.rb b/activerecord/lib/active_record/connection_adapters/postgresql/oid/date_time.rb
index 2c04c46131..424769f765 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql/oid/date_time.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql/oid/date_time.rb
@@ -4,18 +4,14 @@ module ActiveRecord
module OID # :nodoc:
class DateTime < Type::DateTime # :nodoc:
def cast_value(value)
- if value.is_a?(::String)
- case value
- when 'infinity' then ::Float::INFINITY
- when '-infinity' then -::Float::INFINITY
- when / BC$/
- astronomical_year = format("%04d", -value[/^\d+/].to_i + 1)
- super(value.sub(/ BC$/, "").sub(/^\d+/, astronomical_year))
- else
- super
- end
+ case value
+ when 'infinity' then ::Float::INFINITY
+ when '-infinity' then -::Float::INFINITY
+ when / BC$/
+ astronomical_year = format("%04d", -value[/^\d+/].to_i + 1)
+ super(value.sub(/ BC$/, "").sub(/^\d+/, astronomical_year))
else
- value
+ super
end
end
end