From a49615d0dfc4de482a63f9ec6c425b3ad8da2181 Mon Sep 17 00:00:00 2001 From: Raimonds Simanovskis Date: Sun, 15 Mar 2009 14:28:07 +0200 Subject: [PATCH] disabled base_test.rb tests that were not Oracle compatible (TIME datatype is not supported on Oracle, UPDATE does not support ORDER BY) _before_type_cast on Oracle returns Time and not String added Oracle specific schema definition that was missing for test_default_values test --- activerecord/test/cases/base_test.rb | 71 +++++++++++-------- activerecord/test/schema/oracle_specific_schema.rb | 19 +++++ 2 files changed, 60 insertions(+), 30 deletions(-) create mode 100644 activerecord/test/schema/oracle_specific_schema.rb diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb index 99d7796..822ebc5 100755 --- a/activerecord/test/cases/base_test.rb +++ b/activerecord/test/cases/base_test.rb @@ -145,7 +145,12 @@ class BasicsTest < ActiveRecord::TestCase def test_read_attributes_before_type_cast_on_datetime developer = Developer.find(:first) - assert_equal developer.created_at.to_s(:db) , developer.attributes_before_type_cast["created_at"] + # Oracle adapter returns Time before type cast + unless current_adapter?(:OracleAdapter) + assert_equal developer.created_at.to_s(:db) , developer.attributes_before_type_cast["created_at"] + else + assert_equal developer.created_at.to_s(:db) , developer.attributes_before_type_cast["created_at"].to_s(:db) + end end def test_hash_content @@ -681,21 +686,24 @@ class BasicsTest < ActiveRecord::TestCase end end - def test_update_all_ignores_order_without_limit_from_association - author = authors(:david) - assert_nothing_raised do - assert_equal author.posts_with_comments_and_categories.length, author.posts_with_comments_and_categories.update_all([ "body = ?", "bulk update!" ]) + # Oracle UPDATE does not support ORDER BY + unless current_adapter?(:OracleAdapter) + def test_update_all_ignores_order_without_limit_from_association + author = authors(:david) + assert_nothing_raised do + assert_equal author.posts_with_comments_and_categories.length, author.posts_with_comments_and_categories.update_all([ "body = ?", "bulk update!" ]) + end end - end - def test_update_all_with_order_and_limit_updates_subset_only - author = authors(:david) - assert_nothing_raised do - assert_equal 1, author.posts_sorted_by_id_limited.size - assert_equal 2, author.posts_sorted_by_id_limited.find(:all, :limit => 2).size - assert_equal 1, author.posts_sorted_by_id_limited.update_all([ "body = ?", "bulk update!" ]) - assert_equal "bulk update!", posts(:welcome).body - assert_not_equal "bulk update!", posts(:thinking).body + def test_update_all_with_order_and_limit_updates_subset_only + author = authors(:david) + assert_nothing_raised do + assert_equal 1, author.posts_sorted_by_id_limited.size + assert_equal 2, author.posts_sorted_by_id_limited.find(:all, :limit => 2).size + assert_equal 1, author.posts_sorted_by_id_limited.update_all([ "body = ?", "bulk update!" ]) + assert_equal "bulk update!", posts(:welcome).body + assert_not_equal "bulk update!", posts(:thinking).body + end end end @@ -1116,22 +1124,25 @@ class BasicsTest < ActiveRecord::TestCase Topic.skip_time_zone_conversion_for_attributes = [] end - def test_multiparameter_attributes_on_time_only_column_with_time_zone_aware_attributes_does_not_do_time_zone_conversion - ActiveRecord::Base.time_zone_aware_attributes = true - ActiveRecord::Base.default_timezone = :utc - Time.zone = ActiveSupport::TimeZone[-28800] - attributes = { - "bonus_time(1i)" => "2000", "bonus_time(2i)" => "1", "bonus_time(3i)" => "1", - "bonus_time(4i)" => "16", "bonus_time(5i)" => "24" - } - topic = Topic.find(1) - topic.attributes = attributes - assert_equal Time.utc(2000, 1, 1, 16, 24, 0), topic.bonus_time - assert topic.bonus_time.utc? - ensure - ActiveRecord::Base.time_zone_aware_attributes = false - ActiveRecord::Base.default_timezone = :local - Time.zone = nil + # Oracle, and Sybase do not have a TIME datatype. + unless current_adapter?(:OracleAdapter, :SybaseAdapter) + def test_multiparameter_attributes_on_time_only_column_with_time_zone_aware_attributes_does_not_do_time_zone_conversion + ActiveRecord::Base.time_zone_aware_attributes = true + ActiveRecord::Base.default_timezone = :utc + Time.zone = ActiveSupport::TimeZone[-28800] + attributes = { + "bonus_time(1i)" => "2000", "bonus_time(2i)" => "1", "bonus_time(3i)" => "1", + "bonus_time(4i)" => "16", "bonus_time(5i)" => "24" + } + topic = Topic.find(1) + topic.attributes = attributes + assert_equal Time.utc(2000, 1, 1, 16, 24, 0), topic.bonus_time + assert topic.bonus_time.utc? + ensure + ActiveRecord::Base.time_zone_aware_attributes = false + ActiveRecord::Base.default_timezone = :local + Time.zone = nil + end end def test_multiparameter_attributes_on_time_with_empty_seconds diff --git a/activerecord/test/schema/oracle_specific_schema.rb b/activerecord/test/schema/oracle_specific_schema.rb new file mode 100644 index 0000000..bf6ab2d --- /dev/null +++ b/activerecord/test/schema/oracle_specific_schema.rb @@ -0,0 +1,19 @@ +ActiveRecord::Schema.define do + + execute "drop table test_oracle_defaults" rescue nil + execute "drop sequence test_oracle_defaults_seq" rescue nil + + execute <<-SQL +create table test_oracle_defaults ( + id integer not null primary key, + test_char char(1) default 'X' not null, + test_string varchar2(20) default 'hello' not null, + test_int integer default 3 not null +) + SQL + + execute <<-SQL +create sequence test_oracle_defaults_seq minvalue 10000 + SQL + +end -- 1.6.0.4