diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2007-03-06 09:39:50 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2007-03-06 09:39:50 +0000 |
commit | 7b9824f6e2b4df7e8b6abf8720270ae755712895 (patch) | |
tree | 568c89a1f3b653b646d98e595e5af8a4a56c58fb /activerecord | |
parent | 1e9e198cc5c053a9137de78d524412105ac20065 (diff) | |
download | rails-7b9824f6e2b4df7e8b6abf8720270ae755712895.tar.gz rails-7b9824f6e2b4df7e8b6abf8720270ae755712895.tar.bz2 rails-7b9824f6e2b4df7e8b6abf8720270ae755712895.zip |
Oracle: overflow Time to DateTime. Closes #7718.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6348 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/CHANGELOG | 2 | ||||
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/oracle_adapter.rb | 7 | ||||
-rwxr-xr-x | activerecord/test/abstract_unit.rb | 2 | ||||
-rwxr-xr-x | activerecord/test/associations_test.rb | 4 | ||||
-rwxr-xr-x | activerecord/test/base_test.rb | 3 |
5 files changed, 12 insertions, 6 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG index 5fcfe3b5e2..2e523029f5 100644 --- a/activerecord/CHANGELOG +++ b/activerecord/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Oracle: overflow Time to DateTime. #7718 [Michael Schoen] + * PostgreSQL: don't use async_exec and async_query with postgres-pr. #7727 [flowdelic] * Fix has_many :through << with custom foreign keys. #6466, #7153 [naffis, Rich Collins] diff --git a/activerecord/lib/active_record/connection_adapters/oracle_adapter.rb b/activerecord/lib/active_record/connection_adapters/oracle_adapter.rb index 7e6ef121e2..0dc0513356 100644 --- a/activerecord/lib/active_record/connection_adapters/oracle_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/oracle_adapter.rb @@ -507,8 +507,11 @@ begin when OCI8::LOB name == 'Writable Large Object' ? row[i]: row[i].read when OraDate - (row[i].hour == 0 and row[i].minute == 0 and row[i].second == 0) ? - row[i].to_date : row[i].to_time + if emulate_dates && (row[i].hour == 0 && row[i].minute == 0 && row[i].second == 0) + row[i].to_date + else + row[i].to_time rescue row[i].to_datetime + end else row[i] end unless col == 'raw_rnum_' end diff --git a/activerecord/test/abstract_unit.rb b/activerecord/test/abstract_unit.rb index 5a15871279..5e94fa11b4 100755 --- a/activerecord/test/abstract_unit.rb +++ b/activerecord/test/abstract_unit.rb @@ -55,8 +55,8 @@ def current_adapter?(*types) end def uses_mocha(test_name) + require 'rubygems' require 'mocha' - require 'stubba' yield rescue LoadError $stderr.puts "Skipping #{test_name} tests. `gem install mocha` and try again." diff --git a/activerecord/test/associations_test.rb b/activerecord/test/associations_test.rb index 4315570c5c..db4e4118f4 100755 --- a/activerecord/test/associations_test.rb +++ b/activerecord/test/associations_test.rb @@ -1515,7 +1515,7 @@ class HasAndBelongsToManyAssociationsTest < Test::Unit::TestCase assert_equal 2, ken.projects(true).size kenReloaded = Developer.find_by_name 'Ken' - kenReloaded.projects.each {|prj| assert_date_from_db(now, prj.joined_on)} + kenReloaded.projects.each {|prj| assert_date_from_db(now, prj.joined_on.to_date)} end def test_habtm_saving_multiple_relationships @@ -1653,7 +1653,7 @@ class HasAndBelongsToManyAssociationsTest < Test::Unit::TestCase end def test_additional_columns_from_join_table - assert_date_from_db Date.new(2004, 10, 10), Developer.find(1).projects.first.joined_on + assert_date_from_db Date.new(2004, 10, 10), Developer.find(1).projects.first.joined_on.to_date end def test_destroy_all diff --git a/activerecord/test/base_test.rb b/activerecord/test/base_test.rb index f2991bc721..cbc144f57a 100755 --- a/activerecord/test/base_test.rb +++ b/activerecord/test/base_test.rb @@ -369,8 +369,9 @@ class BasicsTest < Test::Unit::TestCase # SQL Server doesn't have a separate column type just for dates, so all are returned as time return true if current_adapter?(:SQLServerAdapter) - if current_adapter?(:SybaseAdapter) + if current_adapter?(:SybaseAdapter, :OracleAdapter) # Sybase ctlib does not (yet?) support the date type; use datetime instead. + # Oracle treats all dates/times as Time. assert_kind_of( Time, Topic.find(1).last_read, "The last_read attribute should be of the Time class" |