diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-09-05 06:26:53 -0700 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-09-05 06:26:53 -0700 |
commit | 91183baa6d54428da7ea466f0a854de2e631dd64 (patch) | |
tree | 305e673886c4c629757eee8f8ebf1783cf54bff4 /activerecord/lib/active_record/connection_adapters | |
parent | 9e0a14f5e2baa7190a9679007b8abad800e48fff (diff) | |
parent | acf583a5e00be0fb684f73ad51cdad0237c981b2 (diff) | |
download | rails-91183baa6d54428da7ea466f0a854de2e631dd64.tar.gz rails-91183baa6d54428da7ea466f0a854de2e631dd64.tar.bz2 rails-91183baa6d54428da7ea466f0a854de2e631dd64.zip |
Merge pull request #7337 from adzap/string_to_dummy_time
Fix for time type columns with invalid time value
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/column.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/column.rb b/activerecord/lib/active_record/connection_adapters/column.rb index 1445bb3b2f..d0237848c7 100644 --- a/activerecord/lib/active_record/connection_adapters/column.rb +++ b/activerecord/lib/active_record/connection_adapters/column.rb @@ -178,7 +178,13 @@ module ActiveRecord return string unless string.is_a?(String) return nil if string.blank? - string_to_time "2000-01-01 #{string}" + dummy_time_string = "2000-01-01 #{string}" + + fast_string_to_time(dummy_time_string) || begin + time_hash = Date._parse(dummy_time_string) + return nil if time_hash[:hour].nil? + new_time(*time_hash.values_at(:year, :mon, :mday, :hour, :min, :sec, :sec_fraction)) + end end # convert something to a boolean |