From eec90bab2815642d1771c9f9c37bd5a0bcd6fc9d Mon Sep 17 00:00:00 2001 From: Raimonds Simanovskis Date: Fri, 7 Aug 2009 17:18:45 +0300 Subject: create DateTime value with local offset as later it is compared to Time value with local offset (otherwise test is failing for oracle_enhanced JDBC adapter) --- activerecord/test/cases/date_time_test.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/activerecord/test/cases/date_time_test.rb b/activerecord/test/cases/date_time_test.rb index 36e1caa0b6..a8b4b7a096 100644 --- a/activerecord/test/cases/date_time_test.rb +++ b/activerecord/test/cases/date_time_test.rb @@ -5,7 +5,9 @@ require 'models/task' class DateTimeTest < ActiveRecord::TestCase def test_saves_both_date_and_time time_values = [1807, 2, 10, 15, 30, 45] - now = DateTime.civil(*time_values) + # create DateTime value with local time zone offset + local_offset = Rational(Time.local_time(*time_values).utc_offset, 86400) + now = DateTime.civil(*(time_values + [local_offset])) task = Task.new task.starting = now -- cgit v1.2.3 From 8136230cca4ff7550f9fbc786a4327bd520d27cb Mon Sep 17 00:00:00 2001 From: Raimonds Simanovskis Date: Mon, 10 Aug 2009 17:25:53 +0300 Subject: Explicitly set Topic model last_read attribute as Date value when Oracle enhanced adapter is used (otherwise some tests are failing which assume that this attribute will have Date value) --- activerecord/test/cases/base_test.rb | 7 ++++--- activerecord/test/models/topic.rb | 6 ++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb index 1d883f7ea8..36c572b5e7 100755 --- a/activerecord/test/cases/base_test.rb +++ b/activerecord/test/cases/base_test.rb @@ -430,14 +430,14 @@ class BasicsTest < ActiveRecord::TestCase end def test_preserving_date_objects - if current_adapter?(:SybaseAdapter, :OracleAdapter) + if current_adapter?(:SybaseAdapter) # 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" ) else + # Oracle enhanced adapter allows to define Date attributes in model class (see topic.rb) assert_kind_of( Date, Topic.find(1).last_read, "The last_read attribute should be of the Date class" @@ -2125,10 +2125,11 @@ class BasicsTest < ActiveRecord::TestCase assert_equal "integer", xml.elements["//parent-id"].attributes['type'] assert_equal "true", xml.elements["//parent-id"].attributes['nil'] - if current_adapter?(:SybaseAdapter, :OracleAdapter) + if current_adapter?(:SybaseAdapter) assert_equal last_read_in_current_timezone, xml.elements["//last-read"].text assert_equal "datetime" , xml.elements["//last-read"].attributes['type'] else + # Oracle enhanced adapter allows to define Date attributes in model class (see topic.rb) assert_equal "2004-04-15", xml.elements["//last-read"].text assert_equal "date" , xml.elements["//last-read"].attributes['type'] end diff --git a/activerecord/test/models/topic.rb b/activerecord/test/models/topic.rb index 91fc7c9416..617f01b47d 100644 --- a/activerecord/test/models/topic.rb +++ b/activerecord/test/models/topic.rb @@ -43,6 +43,12 @@ class Topic < ActiveRecord::Base before_create :default_written_on before_destroy :destroy_children + # Explicitly define as :date column so that returned Oracle DATE values would be typecasted to Date and not Time. + # Some tests depend on assumption that this attribute will have Date values. + if current_adapter?(:OracleEnhancedAdapter) + set_date_columns :last_read + end + def parent Topic.find(parent_id) end -- cgit v1.2.3 From 6356a48faa07908e7eb1759b0a849adc9e0a1d97 Mon Sep 17 00:00:00 2001 From: Raimonds Simanovskis Date: Mon, 10 Aug 2009 17:32:38 +0300 Subject: Reduced size of table name prefix and suffix in migrations test as in Oracle identifier name cannot be larger than 30 characters --- activerecord/test/cases/migration_test.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/activerecord/test/cases/migration_test.rb b/activerecord/test/cases/migration_test.rb index b5fa258f7b..5313274f3e 100644 --- a/activerecord/test/cases/migration_test.rb +++ b/activerecord/test/cases/migration_test.rb @@ -30,13 +30,14 @@ if ActiveRecord::Base.connection.supports_migrations? conn = ActiveRecord::Base.connection conn.drop_table(ActiveRecord::Migrator.schema_migrations_table_name) if conn.table_exists?(ActiveRecord::Migrator.schema_migrations_table_name) - ActiveRecord::Base.table_name_prefix = 'foo_' - ActiveRecord::Base.table_name_suffix = '_bar' + # Use shorter prefix and suffix as in Oracle database identifier cannot be larger than 30 characters + ActiveRecord::Base.table_name_prefix = 'p_' + ActiveRecord::Base.table_name_suffix = '_s' conn.drop_table(ActiveRecord::Migrator.schema_migrations_table_name) if conn.table_exists?(ActiveRecord::Migrator.schema_migrations_table_name) conn.initialize_schema_migrations_table - assert_equal "foo_unique_schema_migrations_bar", conn.indexes(ActiveRecord::Migrator.schema_migrations_table_name)[0][:name] + assert_equal "p_unique_schema_migrations_s", conn.indexes(ActiveRecord::Migrator.schema_migrations_table_name)[0][:name] ensure ActiveRecord::Base.table_name_prefix = "" ActiveRecord::Base.table_name_suffix = "" -- cgit v1.2.3 From f12f3776806d5c6f003533b5bddb96070f0f720d Mon Sep 17 00:00:00 2001 From: Raimonds Simanovskis Date: Tue, 11 Aug 2009 18:29:32 +0300 Subject: Oracle enhanced adapter now supports shortening of default generated index names, some additional tests now pass --- activerecord/test/cases/migration_test.rb | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/activerecord/test/cases/migration_test.rb b/activerecord/test/cases/migration_test.rb index 5313274f3e..a0237d57a7 100644 --- a/activerecord/test/cases/migration_test.rb +++ b/activerecord/test/cases/migration_test.rb @@ -84,13 +84,17 @@ if ActiveRecord::Base.connection.supports_migrations? # Orcl nds shrt indx nms. Sybs 2. # OpenBase does not have named indexes. You must specify a single column name - unless current_adapter?(:OracleAdapter, :SybaseAdapter, :OpenBaseAdapter) + unless current_adapter?(:SybaseAdapter, :OpenBaseAdapter) assert_nothing_raised { Person.connection.add_index("people", ["last_name", "first_name"]) } assert_nothing_raised { Person.connection.remove_index("people", :column => ["last_name", "first_name"]) } - assert_nothing_raised { Person.connection.add_index("people", ["last_name", "first_name"]) } - assert_nothing_raised { Person.connection.remove_index("people", :name => "index_people_on_last_name_and_first_name") } - assert_nothing_raised { Person.connection.add_index("people", ["last_name", "first_name"]) } - assert_nothing_raised { Person.connection.remove_index("people", "last_name_and_first_name") } + # Oracle adapter cannot have specified index name larger than 30 characters + # Oracle adapter is shortening index name when just column list is given + unless current_adapter?(:OracleAdapter) + assert_nothing_raised { Person.connection.add_index("people", ["last_name", "first_name"]) } + assert_nothing_raised { Person.connection.remove_index("people", :name => "index_people_on_last_name_and_first_name") } + assert_nothing_raised { Person.connection.add_index("people", ["last_name", "first_name"]) } + assert_nothing_raised { Person.connection.remove_index("people", "last_name_and_first_name") } + end assert_nothing_raised { Person.connection.add_index("people", ["last_name", "first_name"]) } assert_nothing_raised { Person.connection.remove_index("people", ["last_name", "first_name"]) } assert_nothing_raised { Person.connection.add_index("people", ["last_name"], :length => 10) } @@ -737,13 +741,7 @@ if ActiveRecord::Base.connection.supports_migrations? table.column :hat_size, :integer table.column :hat_style, :string, :limit => 100 end - # Oracle index names should be 30 or less characters - if current_adapter?(:OracleAdapter) - ActiveRecord::Base.connection.add_index "hats", ["hat_style", "hat_size"], :unique => true, - :name => 'index_hats_on_hat_style_size' - else - ActiveRecord::Base.connection.add_index "hats", ["hat_style", "hat_size"], :unique => true - end + ActiveRecord::Base.connection.add_index "hats", ["hat_style", "hat_size"], :unique => true assert_nothing_raised { Person.connection.remove_column("hats", "hat_size") } ensure -- cgit v1.2.3 From 9bf7b6334fae71821c2056ae2e6e8461ec3f73be Mon Sep 17 00:00:00 2001 From: Raimonds Simanovskis Date: Fri, 18 Sep 2009 18:56:55 +0300 Subject: do order by id when finding first fixture to ensure that it is correct one (as otherwise was failing under JRuby and oracle_enhanced adapter) --- activerecord/test/cases/associations/has_many_associations_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/activerecord/test/cases/associations/has_many_associations_test.rb b/activerecord/test/cases/associations/has_many_associations_test.rb index 8e5bc56008..45c7498013 100644 --- a/activerecord/test/cases/associations/has_many_associations_test.rb +++ b/activerecord/test/cases/associations/has_many_associations_test.rb @@ -511,7 +511,7 @@ class HasManyAssociationsTest < ActiveRecord::TestCase end def test_deleting_updates_counter_cache - topic = Topic.first + topic = Topic.first(:order => "id ASC") assert_equal topic.replies.to_a.size, topic.replies_count topic.replies.delete(topic.replies.first) -- cgit v1.2.3 From 464b7f3ddcf5e9b23741862bf8c7a49f61792de3 Mon Sep 17 00:00:00 2001 From: Raimonds Simanovskis Date: Fri, 23 Oct 2009 18:20:03 +0300 Subject: test fixes for Oracle enhanced adapter: latest oracle_enhanced adapter does automatic shortening of index names ignore select from all_triggers table in assert_queries --- activerecord/test/cases/migration_test.rb | 4 ++-- activerecord/test/connections/native_oracle/connection.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/activerecord/test/cases/migration_test.rb b/activerecord/test/cases/migration_test.rb index a0237d57a7..1edec66c25 100644 --- a/activerecord/test/cases/migration_test.rb +++ b/activerecord/test/cases/migration_test.rb @@ -1374,8 +1374,8 @@ if ActiveRecord::Base.connection.supports_migrations? return unless current_adapter? :OracleAdapter # table name is 29 chars, the standard sequence name will - # be 33 chars and fail - assert_raise(ActiveRecord::StatementInvalid) do + # be 33 chars and should be shortened + assert_nothing_raised do begin Person.connection.create_table :table_with_name_thats_just_ok do |t| t.column :foo, :string, :null => false diff --git a/activerecord/test/connections/native_oracle/connection.rb b/activerecord/test/connections/native_oracle/connection.rb index c8183dc0fb..a8ff462dd7 100644 --- a/activerecord/test/connections/native_oracle/connection.rb +++ b/activerecord/test/connections/native_oracle/connection.rb @@ -53,7 +53,7 @@ Course.establish_connection 'arunit2' # for assert_queries test helper ActiveRecord::Base.connection.class.class_eval do - IGNORED_SELECT_SQL = [/^select .*nextval/i, /^SAVEPOINT/, /^ROLLBACK TO SAVEPOINT/, /^RELEASE SAVEPOINT/, /^\s*select .* from all_tab_columns/im] + IGNORED_SELECT_SQL = [/^select .*nextval/i, /^SAVEPOINT/, /^ROLLBACK TO SAVEPOINT/, /^RELEASE SAVEPOINT/, /^\s*select .* from (all_tab_columns|all_triggers)/im] def select_with_query_record(sql, name = nil, return_column_names = false) $queries_executed ||= [] -- cgit v1.2.3 From a83e6b1b6aa8ee67a47658ed27481e38aa2a62da Mon Sep 17 00:00:00 2001 From: Raimonds Simanovskis Date: Mon, 15 Feb 2010 00:38:29 +0200 Subject: downcase table names in aliased_table_name_for and references_eager_loaded_tables? methods (as Oracle quoted table names are in uppercase) --- activerecord/lib/active_record/relation.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb index 4e62187449..b6b4085ec0 100644 --- a/activerecord/lib/active_record/relation.rb +++ b/activerecord/lib/active_record/relation.rb @@ -356,13 +356,15 @@ module ActiveRecord end def references_eager_loaded_tables? - joined_tables = (tables_in_string(arel.joins(arel)) + [table.name, table.table_alias]).compact.uniq + # always convert table names to downcase as in Oracle quoted table names are in uppercase + joined_tables = (tables_in_string(arel.joins(arel)) + [table.name, table.table_alias]).compact.map(&:downcase).uniq (tables_in_string(to_sql) - joined_tables).any? end def tables_in_string(string) return [] if string.blank? - string.scan(/([a-zA-Z_][\.\w]+).?\./).flatten.uniq + # always convert table names to downcase as in Oracle quoted table names are in uppercase + string.scan(/([a-zA-Z_][\.\w]+).?\./).flatten.map(&:downcase).uniq end end -- cgit v1.2.3 From a82e06709179791e6b0a3bca37113f144dcefbb8 Mon Sep 17 00:00:00 2001 From: Raimonds Simanovskis Date: Mon, 15 Feb 2010 17:57:45 +0200 Subject: assert log output match in case insensitive mode to avoid failure when quoted table name is in uppercase (when using Oracle) --- activerecord/test/cases/log_subscriber_test.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/activerecord/test/cases/log_subscriber_test.rb b/activerecord/test/cases/log_subscriber_test.rb index 6ba84fa57b..1f544b4211 100644 --- a/activerecord/test/cases/log_subscriber_test.rb +++ b/activerecord/test/cases/log_subscriber_test.rb @@ -27,7 +27,7 @@ class LogSubscriberTest < ActiveSupport::TestCase wait assert_equal 1, @logger.logged(:debug).size assert_match(/Developer Load/, @logger.logged(:debug).last) - assert_match(/SELECT .*?FROM .?developers.?/, @logger.logged(:debug).last) + assert_match(/SELECT .*?FROM .?developers.?/i, @logger.logged(:debug).last) end def test_cached_queries @@ -38,6 +38,6 @@ class LogSubscriberTest < ActiveSupport::TestCase wait assert_equal 2, @logger.logged(:debug).size assert_match(/CACHE/, @logger.logged(:debug).last) - assert_match(/SELECT .*?FROM .?developers.?/, @logger.logged(:debug).last) + assert_match(/SELECT .*?FROM .?developers.?/i, @logger.logged(:debug).last) end end -- cgit v1.2.3 From 5fcaf917612c61174f55bbd2301131ccdbec51fb Mon Sep 17 00:00:00 2001 From: Raimonds Simanovskis Date: Tue, 16 Feb 2010 21:43:13 +0200 Subject: fix conditions when DateTime#to_date and DateTime#xmlschema methods are defined --- activesupport/lib/active_support/core_ext/date_time/conversions.rb | 6 +++--- activesupport/test/abstract_unit.rb | 2 +- activesupport/test/core_ext/date_time_ext_test.rb | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/activesupport/lib/active_support/core_ext/date_time/conversions.rb b/activesupport/lib/active_support/core_ext/date_time/conversions.rb index 24168c7825..c3f0acce25 100644 --- a/activesupport/lib/active_support/core_ext/date_time/conversions.rb +++ b/activesupport/lib/active_support/core_ext/date_time/conversions.rb @@ -60,7 +60,7 @@ class DateTime # Converts self to a Ruby Date object; time portion is discarded def to_date ::Date.new(year, month, day) - end unless method_defined?(:to_date) + end unless instance_methods(false).include?(:to_date) # Attempts to convert self to a Ruby Time object; returns self if out of range of Ruby Time class # If self has an offset other than 0, self will just be returned unaltered, since there's no clean way to map it to a Time @@ -71,7 +71,7 @@ class DateTime # To be able to keep Times, Dates and DateTimes interchangeable on conversions def to_datetime self - end unless method_defined?(:to_datetime) + end unless instance_methods(false).include?(:to_datetime) def self.civil_from_format(utc_or_local, year, month=1, day=1, hour=0, min=0, sec=0) offset = utc_or_local.to_sym == :local ? local_offset : 0 @@ -81,7 +81,7 @@ class DateTime # Converts datetime to an appropriate format for use in XML def xmlschema strftime("%Y-%m-%dT%H:%M:%S%Z") - end unless method_defined?(:xmlschema) + end unless instance_methods(false).include?(:xmlschema) # Converts self to a floating-point number of seconds since the Unix epoch def to_f diff --git a/activesupport/test/abstract_unit.rb b/activesupport/test/abstract_unit.rb index ea6ebca3ce..dd84860a91 100644 --- a/activesupport/test/abstract_unit.rb +++ b/activesupport/test/abstract_unit.rb @@ -18,7 +18,7 @@ ENV['NO_RELOAD'] = '1' require 'active_support' # Include shims until we get off 1.8.6 -require 'active_support/ruby/shim' +require 'active_support/ruby/shim' if RUBY_VERSION < '1.8.7' def uses_memcached(test_name) require 'memcache' diff --git a/activesupport/test/core_ext/date_time_ext_test.rb b/activesupport/test/core_ext/date_time_ext_test.rb index eba8170cda..19d7935211 100644 --- a/activesupport/test/core_ext/date_time_ext_test.rb +++ b/activesupport/test/core_ext/date_time_ext_test.rb @@ -26,11 +26,11 @@ class DateTimeExtCalculationsTest < Test::Unit::TestCase end def test_to_date - assert_equal Date.new(2005, 2, 21), DateTime.new(2005, 2, 21).to_date + assert_equal Date.new(2005, 2, 21), DateTime.new(2005, 2, 21, 14, 30, 0).to_date end def test_to_datetime - assert_equal DateTime.new(2005, 2, 21), DateTime.new(2005, 2, 21).to_datetime + assert_equal DateTime.new(2005, 2, 21, 14, 30, 0), DateTime.new(2005, 2, 21, 14, 30, 0).to_datetime end def test_to_time -- cgit v1.2.3 From c6d6b5016631ae0d2c6f09bb289fb9b54dca9a0a Mon Sep 17 00:00:00 2001 From: Raimonds Simanovskis Date: Sun, 7 Mar 2010 16:46:59 +0200 Subject: ignore selects from data dictionary views when running tests on Oracle --- activerecord/test/connections/native_oracle/connection.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/activerecord/test/connections/native_oracle/connection.rb b/activerecord/test/connections/native_oracle/connection.rb index a8ff462dd7..bb4040058f 100644 --- a/activerecord/test/connections/native_oracle/connection.rb +++ b/activerecord/test/connections/native_oracle/connection.rb @@ -53,7 +53,7 @@ Course.establish_connection 'arunit2' # for assert_queries test helper ActiveRecord::Base.connection.class.class_eval do - IGNORED_SELECT_SQL = [/^select .*nextval/i, /^SAVEPOINT/, /^ROLLBACK TO SAVEPOINT/, /^RELEASE SAVEPOINT/, /^\s*select .* from (all_tab_columns|all_triggers)/im] + IGNORED_SELECT_SQL = [/^select .*nextval/i, /^SAVEPOINT/, /^ROLLBACK TO/, /^\s*select .* from ((all|user)_tab_columns|(all|user)_triggers|(all|user)_constraints)/im] def select_with_query_record(sql, name = nil, return_column_names = false) $queries_executed ||= [] -- cgit v1.2.3 From 05ef038bb955d4a0c9cbda50bf7ff7eb259bdf59 Mon Sep 17 00:00:00 2001 From: Raimonds Simanovskis Date: Sun, 16 May 2010 19:55:21 +0300 Subject: Fixed adapter tests not to assert LIMIT and OFFSET in SQL strings Fixed adapter test cases that were failing in oracle because the asserts were looking for the presence of offset and limit which are not available in oracle. Changed the tests to check that the sql injection is not present in the output so that the tests are database adapter agnostic. --- activerecord/test/cases/adapter_test.rb | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/activerecord/test/cases/adapter_test.rb b/activerecord/test/cases/adapter_test.rb index 9b28766405..0152b7be2a 100644 --- a/activerecord/test/cases/adapter_test.rb +++ b/activerecord/test/cases/adapter_test.rb @@ -145,22 +145,13 @@ class AdapterTest < ActiveRecord::TestCase def test_add_limit_offset_should_sanitize_sql_injection_for_limit_without_comas sql_inject = "1 select * from schema" - assert_equal " LIMIT 1", @connection.add_limit_offset!("", :limit => sql_inject) - if current_adapter?(:MysqlAdapter) - assert_equal " LIMIT 7, 1", @connection.add_limit_offset!("", :limit => sql_inject, :offset => 7) - else - assert_equal " LIMIT 1 OFFSET 7", @connection.add_limit_offset!("", :limit => sql_inject, :offset => 7) - end + assert_no_match /schema/, @connection.add_limit_offset!("", :limit=>sql_inject) + assert_no_match /schema/, @connection.add_limit_offset!("", :limit=>sql_inject, :offset=>7) end def test_add_limit_offset_should_sanitize_sql_injection_for_limit_with_comas sql_inject = "1, 7 procedure help()" - if current_adapter?(:MysqlAdapter) - assert_equal " LIMIT 1,7", @connection.add_limit_offset!("", :limit => sql_inject) - assert_equal " LIMIT 7, 1", @connection.add_limit_offset!("", :limit => '1 ; DROP TABLE USERS', :offset => 7) - else - assert_equal " LIMIT 1,7", @connection.add_limit_offset!("", :limit => sql_inject) - assert_equal " LIMIT 1,7 OFFSET 7", @connection.add_limit_offset!("", :limit => sql_inject, :offset => 7) - end + assert_no_match /procedure/, @connection.add_limit_offset!("", :limit=>sql_inject) + assert_no_match /procedure/, @connection.add_limit_offset!("", :limit=>sql_inject, :offset=>7) end end -- cgit v1.2.3 From edf79a7fe7c78e291c06a6d8be3ae87dabde9afa Mon Sep 17 00:00:00 2001 From: Raimonds Simanovskis Date: Sun, 16 May 2010 20:26:40 +0300 Subject: Downcase quoted table name in regex in count_aliases_from_table_joins Oracle adapter's quote_table_name returns quoted table name in uppercase and therefore it should be downcased before scanning downcased join_sql --- activerecord/lib/active_record/associations.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb index 5b0ba86308..7d5fd8e96c 100755 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -1755,7 +1755,8 @@ module ActiveRecord end def count_aliases_from_table_joins(name) - quoted_name = join_base.active_record.connection.quote_table_name(name.downcase) + # quoted_name should be downcased as some database adapters (Oracle) return quoted name in uppercase + quoted_name = join_base.active_record.connection.quote_table_name(name.downcase).downcase join_sql = join_base.table_joins.to_s.downcase join_sql.blank? ? 0 : # Table names -- cgit v1.2.3 From b0fdd290f4b186e6da9c550336ee610970f2e8a3 Mon Sep 17 00:00:00 2001 From: Raimonds Simanovskis Date: Sun, 16 May 2010 23:40:22 +0300 Subject: fix test_belongs_to_with_primary_key_joins_on_correct_column test on Oracle --- activerecord/test/cases/associations/belongs_to_associations_test.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/activerecord/test/cases/associations/belongs_to_associations_test.rb b/activerecord/test/cases/associations/belongs_to_associations_test.rb index 9258c987ef..fb1e6e7e70 100644 --- a/activerecord/test/cases/associations/belongs_to_associations_test.rb +++ b/activerecord/test/cases/associations/belongs_to_associations_test.rb @@ -37,6 +37,10 @@ class BelongsToAssociationsTest < ActiveRecord::TestCase if current_adapter?(:MysqlAdapter) assert_no_match(/`firm_with_primary_keys_companies`\.`id`/, sql) assert_match(/`firm_with_primary_keys_companies`\.`name`/, sql) + elsif current_adapter?(:OracleAdapter) + # on Oracle aliases are truncated to 30 characters and are quoted in uppercase + assert_no_match(/"firm_with_primary_keys_compani"\."id"/i, sql) + assert_match(/"firm_with_primary_keys_compani"\."name"/i, sql) else assert_no_match(/"firm_with_primary_keys_companies"\."id"/, sql) assert_match(/"firm_with_primary_keys_companies"\."name"/, sql) -- cgit v1.2.3 From c51fa6bdfc202f78907a7d1cb6bce7b0e2562913 Mon Sep 17 00:00:00 2001 From: Raimonds Simanovskis Date: Mon, 17 May 2010 00:19:18 +0300 Subject: ignore raw_sql_ table alias that is used by Oracle adapter --- activerecord/lib/active_record/relation.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb index b6b4085ec0..99c914d7fc 100644 --- a/activerecord/lib/active_record/relation.rb +++ b/activerecord/lib/active_record/relation.rb @@ -364,7 +364,8 @@ module ActiveRecord def tables_in_string(string) return [] if string.blank? # always convert table names to downcase as in Oracle quoted table names are in uppercase - string.scan(/([a-zA-Z_][\.\w]+).?\./).flatten.map(&:downcase).uniq + # ignore raw_sql_ that is used by Oracle adapter as alias for limit/offset subqueries + string.scan(/([a-zA-Z_][\.\w]+).?\./).flatten.map(&:downcase).uniq - ['raw_sql_'] end end -- cgit v1.2.3 From acef8feafa8a44271eb28685e180f8c28b7e4a0f Mon Sep 17 00:00:00 2001 From: Raimonds Simanovskis Date: Fri, 4 Jun 2010 22:58:55 +0300 Subject: compare sorted arrays in relations_test Oracle does not guarantee that SELECT will return records ordered by primary key --- activerecord/test/cases/relations_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb index 4097c5119e..43519db976 100644 --- a/activerecord/test/cases/relations_test.rb +++ b/activerecord/test/cases/relations_test.rb @@ -114,7 +114,7 @@ class RelationTest < ActiveRecord::TestCase def test_select_with_block even_ids = Developer.scoped.select {|d| d.id % 2 == 0 }.map(&:id) - assert_equal [2, 4, 6, 8, 10], even_ids + assert_equal [2, 4, 6, 8, 10], even_ids.sort end def test_finding_with_hash_conditions_on_joined_table -- cgit v1.2.3