Changeset 2761
- Timestamp:
- 10/27/05 08:18:41 (3 years ago)
- Files:
-
- trunk/activerecord/CHANGELOG (modified) (1 diff)
- trunk/activerecord/lib/active_record/associations.rb (modified) (1 diff)
- trunk/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb (modified) (1 diff)
- trunk/activerecord/lib/active_record/connection_adapters/db2_adapter.rb (modified) (2 diffs)
- trunk/activerecord/lib/active_record/connection_adapters/sqlserver_adapter.rb (modified) (1 diff)
- trunk/activerecord/test/abstract_unit.rb (modified) (1 diff)
- trunk/activerecord/test/associations_test.rb (modified) (3 diffs)
- trunk/activerecord/test/base_test.rb (modified) (11 diffs)
- trunk/activerecord/test/deprecated_finder_test.rb (modified) (1 diff)
- trunk/activerecord/test/fixtures_test.rb (modified) (1 diff)
- trunk/activerecord/test/inheritance_test.rb (modified) (1 diff)
- trunk/activerecord/test/schema_dumper_test.rb (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/activerecord/CHANGELOG
r2748 r2761 5 5 * Fixed handling of nil number columns on Oracle and cleaned up tests for Oracle in general #2555 [schoenm@earthlink.net] 6 6 7 * Added quoted_true and quoted_false methods to db2_adapter and cleaned up tests for DB2 #2493[maik schmidt]7 * Added quoted_true and quoted_false methods and tables to db2_adapter and cleaned up tests for DB2 #2493, #2624 [maik schmidt] 8 8 9 9 trunk/activerecord/lib/active_record/associations.rb
r2744 r2761 894 894 construct_finder_sql_for_association_limiting(options), 895 895 "#{name} Load IDs For Limited Eager Loading" 896 ).collect { |id| "'#{id}'"}.join(", ")896 ).collect { |id| connection.quote(id) }.join(", ") 897 897 end 898 898 trunk/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
r2614 r2761 34 34 end 35 35 36 # Does this adapter support migrations ? Backend specific, as the36 # Does this adapter support migrations? Backend specific, as the 37 37 # abstract adapter always returns +false+. 38 38 def supports_migrations? trunk/activerecord/lib/active_record/connection_adapters/db2_adapter.rb
r2739 r2761 1 # Author : Maik Schmidt <contact@maik-schmidt.de>1 # Author/Maintainer: Maik Schmidt <contact@maik-schmidt.de> 2 2 3 3 require 'active_record/connection_adapters/abstract_adapter' … … 114 114 end 115 115 116 def tables(name = nil) 117 stmt = DB2::Statement.new(@connection) 118 result = [] 119 stmt.tables.each { |t| result << t[2].downcase } 120 stmt.free 121 result 122 end 123 116 124 def columns(table_name, name = nil) 117 125 stmt = DB2::Statement.new(@connection) trunk/activerecord/lib/active_record/connection_adapters/sqlserver_adapter.rb
r2586 r2761 11 11 # Modifications (ODBC): Mark Imbriaco <mark.imbriaco@pobox.com> 12 12 # Date: 6/26/2005 13 # 14 # Current maintainer: Ryan Tomayko <rtomayko@gmail.com> 13 15 # 14 16 module ActiveRecord trunk/activerecord/test/abstract_unit.rb
r2416 r2761 18 18 end 19 19 end 20 21 def current_adapter?(type) 22 ActiveRecord::ConnectionAdapters.const_defined?(type) && 23 ActiveRecord::Base.connection.instance_of?(ActiveRecord::ConnectionAdapters.const_get(type)) 24 end trunk/activerecord/test/associations_test.rb
r2705 r2761 1152 1152 # SQL Server doesn't have a separate column type just for dates, 1153 1153 # so the time is in the string and incorrectly formatted 1154 if ActiveRecord::ConnectionAdapters.const_defined? :SQLServerAdapter and ActiveRecord::Base.connection.instance_of?(ActiveRecord::ConnectionAdapters::SQLServerAdapter)1154 if current_adapter?(:SQLServerAdapter) 1155 1155 kenReloaded.projects.each { |prj| assert_equal(sqlnow, prj.joined_on.strftime("%Y/%m/%d 00:00:00")) } 1156 1156 else … … 1246 1246 # SQL Server doesn't have a separate column type just for dates, 1247 1247 # so the time is in the string and incorrectly formatted 1248 if ActiveRecord::ConnectionAdapters.const_defined? :SQLServerAdapter and ActiveRecord::Base.connection.instance_of?(ActiveRecord::ConnectionAdapters::SQLServerAdapter)1248 if current_adapter?(:SQLServerAdapter) 1249 1249 assert_equal Time.mktime(2004, 10, 10).strftime("%Y/%m/%d 00:00:00"), Time.parse(Developer.find(1).projects.first.joined_on).strftime("%Y/%m/%d 00:00:00") 1250 1250 else … … 1267 1267 # SQL Server doesn't have a separate column type just for dates, 1268 1268 # so the time is in the string and incorrectly formatted 1269 if ActiveRecord::ConnectionAdapters.const_defined? :SQLServerAdapter and ActiveRecord::Base.connection.instance_of?(ActiveRecord::ConnectionAdapters::SQLServerAdapter)1269 if current_adapter?(:SQLServerAdapter) 1270 1270 assert_equal Time.now.strftime("%Y/%m/%d 00:00:00"), Time.parse(jamis.projects.select { |p| p.name == projects(:action_controller).name }.first.joined_on).strftime("%Y/%m/%d 00:00:00") 1271 1271 assert_equal Time.now.strftime("%Y/%m/%d 00:00:00"), Time.parse(developers(:jamis).projects.select { |p| p.name == projects(:action_controller).name }.first.joined_on).strftime("%Y/%m/%d 00:00:00") trunk/activerecord/test/base_test.rb
r2748 r2761 116 116 end 117 117 118 def test_attributes_hash 118 def test_case_sensitive_attributes_hash 119 # DB2 is not case-sensitive 120 return true if current_adapter?(:DB2Adapter) 121 119 122 assert_equal @loaded_fixtures['computers']['workstation'].to_hash, Computer.find(:first).attributes 120 123 end … … 221 224 def test_preserving_date_objects 222 225 # SQL Server doesn't have a separate column type just for dates, so all are returned as time 223 if ActiveRecord::ConnectionAdapters.const_defined? :SQLServerAdapter 224 return true if ActiveRecord::Base.connection.instance_of?(ActiveRecord::ConnectionAdapters::SQLServerAdapter) 225 end 226 return true if current_adapter?(:SQLServerAdapter) 226 227 227 228 assert_kind_of( … … 229 230 "The last_read attribute should be of the Date class" 230 231 ) 231 232 end 233 234 def test_preserving_time_objects 232 235 # Oracle does not have a TIME datatype. 233 if ActiveRecord::ConnectionAdapters.const_defined? :OracleAdapter 234 return true if ActiveRecord::Base.connection.instance_of?(ActiveRecord::ConnectionAdapters::OracleAdapter) 235 end 236 return true if current_adapter?(:OCIAdapter) 237 236 238 assert_kind_of( 237 239 Time, Topic.find(1).bonus_time, 238 240 "The bonus_time attribute should be of the Time class" 239 241 ) 240 end 241 242 def test_preserving_time_objects 242 243 243 assert_kind_of( 244 244 Time, Topic.find(1).written_on, … … 385 385 def test_update_all 386 386 # The ADO library doesn't support the number of affected rows 387 if ActiveRecord::ConnectionAdapters.const_defined? :SQLServerAdapter 388 return true if ActiveRecord::Base.connection.instance_of?(ActiveRecord::ConnectionAdapters::SQLServerAdapter) 389 end 387 return true if current_adapter?(:SQLServerAdapter) 388 390 389 assert_equal 2, Topic.update_all("content = 'bulk updated!'") 391 390 assert_equal "bulk updated!", Topic.find(1).content … … 407 406 def test_delete_all 408 407 # The ADO library doesn't support the number of affected rows 409 if ActiveRecord::ConnectionAdapters.const_defined? :SQLServerAdapter 410 return true if ActiveRecord::Base.connection.instance_of?(ActiveRecord::ConnectionAdapters::SQLServerAdapter) 411 end 408 return true if current_adapter?(:SQLServerAdapter) 409 412 410 assert_equal 2, Topic.delete_all 413 411 end … … 472 470 end 473 471 474 # Oracle and SQLServer do not have a TIME datatype.475 unless 'OCI' == ActiveRecord::Base.connection.adapter_name or ActiveRecord::ConnectionAdapters.const_defined?(:SQLServerAdapter)476 def test_utc_as_time_zone477 Topic.default_timezone = :utc 478 attributes = { "bonus_time" => "5:42:00AM" }479 topic = Topic.find(1)480 topic.attributes = attributes481 assert_equal Time.utc(2000, 1, 1, 5, 42, 0), topic.bonus_time482 Topic.default_timezone = :local483 end472 def test_utc_as_time_zone 473 # Oracle and SQLServer do not have a TIME datatype. 474 return true if current_adapter?(:SQLServerAdapter) || current_adapter?(:OCIAdapter) 475 476 Topic.default_timezone = :utc 477 attributes = { "bonus_time" => "5:42:00AM" } 478 topic = Topic.find(1) 479 topic.attributes = attributes 480 assert_equal Time.utc(2000, 1, 1, 5, 42, 0), topic.bonus_time 481 Topic.default_timezone = :local 484 482 end 485 483 … … 588 586 def test_multiparameter_attributes_on_date 589 587 # SQL Server doesn't have a separate column type just for dates, so all are returned as time 590 if ActiveRecord::ConnectionAdapters.const_defined? :SQLServerAdapter 591 return true if ActiveRecord::Base.connection.instance_of?(ActiveRecord::ConnectionAdapters::SQLServerAdapter) 592 end 588 return true if current_adapter?(:SQLServerAdapter) 593 589 594 590 attributes = { "last_read(1i)" => "2004", "last_read(2i)" => "6", "last_read(3i)" => "24" } … … 602 598 def test_multiparameter_attributes_on_date_with_empty_date 603 599 # SQL Server doesn't have a separate column type just for dates, so all are returned as time 604 if ActiveRecord::ConnectionAdapters.const_defined? :SQLServerAdapter 605 return true if ActiveRecord::Base.connection.instance_of?(ActiveRecord::ConnectionAdapters::SQLServerAdapter) 606 end 600 return true if current_adapter?(:SQLServerAdapter) 607 601 608 602 attributes = { "last_read(1i)" => "2004", "last_read(2i)" => "6", "last_read(3i)" => "" } … … 651 645 652 646 def test_attributes_on_dummy_time 653 # Oracle does not have a TIME datatype. 654 if ActiveRecord::ConnectionAdapters.const_defined? :OCIAdapter 655 return true if ActiveRecord::Base.connection.instance_of?(ActiveRecord::ConnectionAdapters::OCIAdapter) 656 end 657 # Sqlserver doesn't either . 658 if ActiveRecord::ConnectionAdapters.const_defined? :SQLServerAdapter 659 return true if ActiveRecord::Base.connection.instance_of?(ActiveRecord::ConnectionAdapters::SQLServerAdapter) 660 end 647 # Oracle and SQL Server does not have a TIME datatype. 648 return true if current_adapter?(:SQLServerAdapter) || current_adapter?(:OCIAdapter) 661 649 662 650 attributes = { … … 739 727 740 728 # TODO: extend defaults tests to other databases! 741 if 'PostgreSQL' == ActiveRecord::Base.connection.adapter_name729 if current_adapter?(:PostgreSQLAdapter) 742 730 def test_default 743 731 default = Default.new … … 1087 1075 1088 1076 private 1089 1090 1077 def assert_readers(model, exceptions) 1091 1078 expected_readers = model.column_names - (model.serialized_attributes.keys + exceptions + ['id']) trunk/activerecord/test/deprecated_finder_test.rb
r2625 r2761 16 16 17 17 def test_find_all_with_prepared_limit_and_offset 18 if ActiveRecord::ConnectionAdapters.const_defined? :OracleAdapter 19 if ActiveRecord::Base.connection.instance_of?(ActiveRecord::ConnectionAdapters::OracleAdapter) 20 assert_raises(ArgumentError) { Entrant.find_all nil, "id ASC", [2, 1] } 21 end 18 if current_adapter?(:OCIAdapter) 19 assert_raises(ArgumentError) { Entrant.find_all nil, "id ASC", [2, 1] } 22 20 else 23 21 entrants = Entrant.find_all nil, "id ASC", [2, 1] trunk/activerecord/test/fixtures_test.rb
r2741 r2761 54 54 def test_inserts_with_pre_and_suffix 55 55 # not supported yet in OCI adapter 56 if ActiveRecord::ConnectionAdapters.const_defined? :OCIAdapter 57 return true if ActiveRecord::Base.connection.instance_of?(ActiveRecord::ConnectionAdapters::OCIAdapter) 58 end 56 return true if current_adapter?(:OCIAdapter) 59 57 60 58 ActiveRecord::Base.connection.create_table :prefix_topics_suffix do |t| trunk/activerecord/test/inheritance_test.rb
r2595 r2761 9 9 def test_a_bad_type_column 10 10 #SQLServer need to turn Identity Insert On before manually inserting into the Identity column 11 if ActiveRecord::ConnectionAdapters.const_defined? :SQLServerAdapter and ActiveRecord::Base.connection.instance_of?(ActiveRecord::ConnectionAdapters::SQLServerAdapter)11 if current_adapter?(:SQLServerAdapter) 12 12 Company.connection.execute "SET IDENTITY_INSERT companies ON" 13 13 end 14 14 Company.connection.insert "INSERT INTO companies (id, type, name) VALUES(100, 'bad_class!', 'Not happening')" 15 15 16 #We then need to turn it back Off before continuing. 16 if ActiveRecord::ConnectionAdapters.const_defined? :SQLServerAdapter and ActiveRecord::Base.connection.instance_of?(ActiveRecord::ConnectionAdapters::SQLServerAdapter)17 if current_adapter?(:SQLServerAdapter) 17 18 Company.connection.execute "SET IDENTITY_INSERT companies OFF" 18 19 end trunk/activerecord/test/schema_dumper_test.rb
r2741 r2761 4 4 5 5 if ActiveRecord::Base.connection.respond_to?(:tables) 6 7 unless ActiveRecord::ConnectionAdapters.const_defined?(:OCIAdapter) && \ 8 ActiveRecord::Base.connection.instance_of?(ActiveRecord::ConnectionAdapters::OCIAdapter) 6 unless current_adapter?(:OCIAdapter) 9 7 10 8 class SchemaDumperTest < Test::Unit::TestCase … … 21 19 22 20 end 23 24 21 end