diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-04-02 08:42:21 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-04-02 08:42:21 +0000 |
commit | c6cc7078544e5954a9ff181a854d77c9b9c94d5a (patch) | |
tree | ce44396c7d6de7d0cfa1c2cc5924e709ce0e72c2 | |
parent | f84044a83f6f9a1c8eeef4091649b862ab78c50d (diff) | |
download | rails-c6cc7078544e5954a9ff181a854d77c9b9c94d5a.tar.gz rails-c6cc7078544e5954a9ff181a854d77c9b9c94d5a.tar.bz2 rails-c6cc7078544e5954a9ff181a854d77c9b9c94d5a.zip |
Fixed auto-stamping of dates (created_on/updated_on) for PostgreSQL #985 [dave@cherryville.org]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1063 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r-- | activerecord/CHANGELOG | 2 | ||||
-rwxr-xr-x | activerecord/lib/active_record/connection_adapters/abstract_adapter.rb | 12 |
2 files changed, 8 insertions, 6 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG index b0b2a1c4ab..d72a50022a 100644 --- a/activerecord/CHANGELOG +++ b/activerecord/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Fixed auto-stamping of dates (created_on/updated_on) for PostgreSQL #985 [dave@cherryville.org] + * Fixed Base.silence/benchmark to only log if a logger has been configured #986 [skaes@web.de] * Added a join parameter as the third argument to Base.find_first and as the second to Base.count #426, #988 [skaes@web.de] diff --git a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb index bc30a94c97..1176b12cbf 100755 --- a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb @@ -205,22 +205,22 @@ module ActiveRecord private def string_to_date(string) - return string if string.is_a?(Date) - date_array = ParseDate.parsedate(string) + return string unless string.is_a?(String) + date_array = ParseDate.parsedate(string.to_s) # treat 0000-00-00 as nil Date.new(date_array[0], date_array[1], date_array[2]) rescue nil end def string_to_time(string) - return string if string.is_a?(Time) - time_array = ParseDate.parsedate(string).compact + return string unless string.is_a?(String) + time_array = ParseDate.parsedate(string.to_s).compact # treat 0000-00-00 00:00:00 as nil Time.send(Base.default_timezone, *time_array) rescue nil end def string_to_dummy_time(string) - return string if string.is_a?(Time) - time_array = ParseDate.parsedate(string) + return string unless string.is_a?(String) + time_array = ParseDate.parsedate(string.to_s) # pad the resulting array with dummy date information time_array[0] = 2000; time_array[1] = 1; time_array[2] = 1; Time.send(Base.default_timezone, *time_array) rescue nil |