ibm_db 0.4.6 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGES +7 -1
- data/README +46 -43
- data/ext/ibm_db.c +361 -326
- data/lib/active_record/connection_adapters/ibm_db_adapter.rb +208 -77
- data/lib/linux32/ibm_db.so +0 -0
- data/test/associations/eager_test.rb +445 -0
- data/test/associations_test.rb +1839 -0
- data/test/fixtures/db_definitions/luw/ibm_db.drop.sql +1 -0
- data/test/fixtures/db_definitions/luw/ibm_db.sql +6 -0
- data/test/migration_test.rb +104 -65
- metadata +5 -2
| @@ -224,3 +224,9 @@ CREATE TABLE numeric_data ( | |
| 224 224 | 
             
              my_house_population DECIMAL(2),
         | 
| 225 225 | 
             
              decimal_number_with_default DECIMAL(3,2) DEFAULT 2.78
         | 
| 226 226 | 
             
            );
         | 
| 227 | 
            +
             | 
| 228 | 
            +
            CREATE TABLE mixed_case_monkeys (
         | 
| 229 | 
            +
              monkeyID INT GENERATED BY DEFAULT AS IDENTITY (START WITH 100),
         | 
| 230 | 
            +
              fleaCount INT DEFAULT 0,
         | 
| 231 | 
            +
              PRIMARY KEY (monkeyID)
         | 
| 232 | 
            +
            );
         | 
    
        data/test/migration_test.rb
    CHANGED
    
    | @@ -59,7 +59,7 @@ if ActiveRecord::Base.connection.supports_migrations? | |
| 59 59 | 
             
                  assert_nothing_raised { Person.connection.remove_index("people", "last_name") }
         | 
| 60 60 |  | 
| 61 61 | 
             
                  # Orcl nds shrt indx nms.  Sybs 2.
         | 
| 62 | 
            -
                  unless current_adapter?(:OracleAdapter, :SybaseAdapter, :IBM_DBAdapter)
         | 
| 62 | 
            +
                  unless current_adapter?(:OracleAdapter, :SybaseAdapter, :IBM_DBAdapter) # incompatible index size
         | 
| 63 63 | 
             
                    assert_nothing_raised { Person.connection.add_index("people", ["last_name", "first_name"]) }
         | 
| 64 64 | 
             
                    assert_nothing_raised { Person.connection.remove_index("people", :column => ["last_name", "first_name"]) }
         | 
| 65 65 | 
             
                    assert_nothing_raised { Person.connection.add_index("people", ["last_name", "first_name"]) }
         | 
| @@ -130,6 +130,29 @@ if ActiveRecord::Base.connection.supports_migrations? | |
| 130 130 | 
             
                  Person.connection.drop_table :testings rescue nil
         | 
| 131 131 | 
             
                end
         | 
| 132 132 |  | 
| 133 | 
            +
                # IBM data servers do not support limits on certain data types (unlike MySQL)
         | 
| 134 | 
            +
                # Limit is supported for the {float, decimal, numeric, varchar, clob, blob} data types.
         | 
| 135 | 
            +
                if current_adapter?(:IBM_DBAdapter)
         | 
| 136 | 
            +
                  def test_no_limits_datatypes_IBM_DB
         | 
| 137 | 
            +
                    clasz = Class.new(ActiveRecord::Base)
         | 
| 138 | 
            +
                    clasz.table_name = 'test_no_limits_datatypes_IBM_DB'
         | 
| 139 | 
            +
                    assert_nothing_raised do
         | 
| 140 | 
            +
                      clasz.connection.create_table clasz.table_name do |t|
         | 
| 141 | 
            +
                        t.column "test_varchar", :string,    :limit => 10
         | 
| 142 | 
            +
                        t.column "test_integer", :integer,   :limit => 5
         | 
| 143 | 
            +
                        t.column "test_double",  :double,    :limit => 10
         | 
| 144 | 
            +
                        t.column "test_date",    :date,      :limit => 10
         | 
| 145 | 
            +
                        t.column "test_time",    :time,      :limit => 10
         | 
| 146 | 
            +
                        t.column "test_tstamp",  :timestamp, :limit => 10
         | 
| 147 | 
            +
                        t.column "test_xml",     :xml,       :limit => 10
         | 
| 148 | 
            +
                        t.column "test_clob",    :text,      :limit => 10000
         | 
| 149 | 
            +
                      end
         | 
| 150 | 
            +
                    end
         | 
| 151 | 
            +
                  ensure
         | 
| 152 | 
            +
                    clasz.connection.drop_table(clasz.table_name) rescue nil
         | 
| 153 | 
            +
                  end
         | 
| 154 | 
            +
                end
         | 
| 155 | 
            +
             | 
| 133 156 | 
             
                def test_create_table_with_limits
         | 
| 134 157 | 
             
                  assert_nothing_raised do
         | 
| 135 158 | 
             
                    Person.connection.create_table :testings do |t|
         | 
| @@ -321,44 +344,50 @@ if ActiveRecord::Base.connection.supports_migrations? | |
| 321 344 | 
             
                  assert !Person.column_methods_hash.include?(:last_name)
         | 
| 322 345 | 
             
                end
         | 
| 323 346 |  | 
| 324 | 
            -
                 | 
| 325 | 
            -
                   | 
| 326 | 
            -
             | 
| 327 | 
            -
             | 
| 328 | 
            -
                     | 
| 329 | 
            -
             | 
| 330 | 
            -
             | 
| 331 | 
            -
             | 
| 332 | 
            -
             | 
| 333 | 
            -
             | 
| 334 | 
            -
             | 
| 335 | 
            -
             | 
| 336 | 
            -
             | 
| 337 | 
            -
             | 
| 338 | 
            -
                     | 
| 339 | 
            -
             | 
| 347 | 
            +
                unless current_adapter?(:IBM_DBAdapter) # rename not supported
         | 
| 348 | 
            +
                  def test_add_rename
         | 
| 349 | 
            +
                    Person.delete_all
         | 
| 350 | 
            +
              
         | 
| 351 | 
            +
                    begin
         | 
| 352 | 
            +
                      Person.connection.add_column "people", "girlfriend", :string
         | 
| 353 | 
            +
                      Person.create :girlfriend => 'bobette'
         | 
| 354 | 
            +
              
         | 
| 355 | 
            +
                      Person.connection.rename_column "people", "girlfriend", "exgirlfriend"
         | 
| 356 | 
            +
              
         | 
| 357 | 
            +
                      Person.reset_column_information
         | 
| 358 | 
            +
                      bob = Person.find(:first)
         | 
| 359 | 
            +
              
         | 
| 360 | 
            +
                      assert_equal "bobette", bob.exgirlfriend
         | 
| 361 | 
            +
                    ensure
         | 
| 362 | 
            +
                      Person.connection.remove_column("people", "girlfriend") rescue nil
         | 
| 363 | 
            +
                      Person.connection.remove_column("people", "exgirlfriend") rescue nil
         | 
| 364 | 
            +
                    end
         | 
| 340 365 | 
             
                  end
         | 
| 341 366 | 
             
                end
         | 
| 342 367 |  | 
| 343 | 
            -
                 | 
| 344 | 
            -
                   | 
| 345 | 
            -
                     | 
| 346 | 
            -
             | 
| 347 | 
            -
             | 
| 348 | 
            -
             | 
| 349 | 
            -
                     | 
| 350 | 
            -
             | 
| 368 | 
            +
                unless current_adapter?(:IBM_DBAdapter) # rename not supported
         | 
| 369 | 
            +
                  def test_rename_column_using_symbol_arguments
         | 
| 370 | 
            +
                    begin
         | 
| 371 | 
            +
                      Person.connection.rename_column :people, :first_name, :nick_name
         | 
| 372 | 
            +
                      Person.reset_column_information
         | 
| 373 | 
            +
                      assert Person.column_names.include?("nick_name")
         | 
| 374 | 
            +
                    ensure
         | 
| 375 | 
            +
                      Person.connection.remove_column("people","nick_name")
         | 
| 376 | 
            +
                      Person.connection.add_column("people","first_name", :string)
         | 
| 377 | 
            +
                    end
         | 
| 351 378 | 
             
                  end
         | 
| 352 379 | 
             
                end
         | 
| 353 380 |  | 
| 354 | 
            -
                 | 
| 355 | 
            -
                   | 
| 356 | 
            -
                     | 
| 357 | 
            -
             | 
| 358 | 
            -
             | 
| 359 | 
            -
             | 
| 360 | 
            -
                     | 
| 361 | 
            -
             | 
| 381 | 
            +
                unless current_adapter?(:IBM_DBAdapter) # rename not supported
         | 
| 382 | 
            +
                  def test_rename_column
         | 
| 383 | 
            +
                    begin
         | 
| 384 | 
            +
                      Person.connection.rename_column "people", "first_name", "nick_name"
         | 
| 385 | 
            +
                      Person.reset_column_information
         | 
| 386 | 
            +
                      assert Person.column_names.include?("nick_name")
         | 
| 387 | 
            +
                    ensure
         | 
| 388 | 
            +
                      Person.connection.remove_column("people","nick_name")
         | 
| 389 | 
            +
                      Person.connection.add_column("people","first_name", :string)
         | 
| 390 | 
            +
                    end
         | 
| 362 391 | 
             
                  end
         | 
| 363 392 | 
             
                end
         | 
| 364 393 |  | 
| @@ -406,35 +435,37 @@ if ActiveRecord::Base.connection.supports_migrations? | |
| 406 435 | 
             
                  end
         | 
| 407 436 | 
             
                end
         | 
| 408 437 |  | 
| 409 | 
            -
                 | 
| 410 | 
            -
                   | 
| 411 | 
            -
             | 
| 412 | 
            -
             | 
| 413 | 
            -
             | 
| 414 | 
            -
             | 
| 415 | 
            -
             | 
| 416 | 
            -
             | 
| 417 | 
            -
             | 
| 418 | 
            -
             | 
| 419 | 
            -
             | 
| 420 | 
            -
             | 
| 421 | 
            -
             | 
| 422 | 
            -
             | 
| 423 | 
            -
             | 
| 424 | 
            -
             | 
| 425 | 
            -
             | 
| 426 | 
            -
                   | 
| 438 | 
            +
                unless current_adapter?(:IBM_DBAdapter) # incompatible types changes
         | 
| 439 | 
            +
                  def test_change_column
         | 
| 440 | 
            +
                    Person.connection.add_column 'people', 'age', :integer
         | 
| 441 | 
            +
                    old_columns = Person.connection.columns(Person.table_name, "#{name} Columns")
         | 
| 442 | 
            +
                    assert old_columns.find { |c| c.name == 'age' and c.type == :integer }
         | 
| 443 | 
            +
                    assert_nothing_raised { Person.connection.change_column "people", "age", :string }
         | 
| 444 | 
            +
                    new_columns = Person.connection.columns(Person.table_name, "#{name} Columns")
         | 
| 445 | 
            +
                    assert_nil new_columns.find { |c| c.name == 'age' and c.type == :integer }
         | 
| 446 | 
            +
                    assert new_columns.find { |c| c.name == 'age' and c.type == :string }
         | 
| 447 | 
            +
              
         | 
| 448 | 
            +
                    old_columns = Topic.connection.columns(Topic.table_name, "#{name} Columns")
         | 
| 449 | 
            +
                    assert old_columns.find { |c| c.name == 'approved' and c.type == :boolean and c.default == true }
         | 
| 450 | 
            +
                    assert_nothing_raised { Topic.connection.change_column :topics, :approved, :boolean, :default => false }
         | 
| 451 | 
            +
                    new_columns = Topic.connection.columns(Topic.table_name, "#{name} Columns")     
         | 
| 452 | 
            +
                    assert_nil new_columns.find { |c| c.name == 'approved' and c.type == :boolean and c.default == true }
         | 
| 453 | 
            +
                    assert new_columns.find { |c| c.name == 'approved' and c.type == :boolean and c.default == false }
         | 
| 454 | 
            +
                    assert_nothing_raised { Topic.connection.change_column :topics, :approved, :boolean, :default => true }
         | 
| 455 | 
            +
                  end
         | 
| 427 456 | 
             
                end
         | 
| 428 457 |  | 
| 429 458 | 
             
                def test_change_column_with_nil_default
         | 
| 430 459 | 
             
                  Person.connection.add_column "people", "contributor", :boolean, :default => true
         | 
| 431 460 | 
             
                  Person.reset_column_information
         | 
| 432 461 | 
             
                  assert Person.new.contributor?
         | 
| 433 | 
            -
             | 
| 434 | 
            -
                   | 
| 435 | 
            -
             | 
| 436 | 
            -
             | 
| 437 | 
            -
             | 
| 462 | 
            +
             | 
| 463 | 
            +
                  unless current_adapter?(:IBM_DBAdapter) # incompatible types changes
         | 
| 464 | 
            +
                    assert_nothing_raised { Person.connection.change_column "people", "contributor", :boolean, :default => nil }
         | 
| 465 | 
            +
                    Person.reset_column_information
         | 
| 466 | 
            +
                    assert !Person.new.contributor?
         | 
| 467 | 
            +
                    assert_nil Person.new.contributor
         | 
| 468 | 
            +
                  end
         | 
| 438 469 | 
             
                end
         | 
| 439 470 |  | 
| 440 471 | 
             
                def test_change_column_with_new_default
         | 
| @@ -442,9 +473,11 @@ if ActiveRecord::Base.connection.supports_migrations? | |
| 442 473 | 
             
                  Person.reset_column_information
         | 
| 443 474 | 
             
                  assert Person.new.administrator?
         | 
| 444 475 |  | 
| 445 | 
            -
                   | 
| 446 | 
            -
             | 
| 447 | 
            -
             | 
| 476 | 
            +
                  unless current_adapter?(:IBM_DBAdapter) # incompatible types changes
         | 
| 477 | 
            +
                    assert_nothing_raised { Person.connection.change_column "people", "administrator", :boolean, :default => false }
         | 
| 478 | 
            +
                    Person.reset_column_information
         | 
| 479 | 
            +
                    assert !Person.new.administrator?
         | 
| 480 | 
            +
                  end
         | 
| 448 481 | 
             
                end
         | 
| 449 482 |  | 
| 450 483 | 
             
                def test_change_column_default
         | 
| @@ -496,13 +529,13 @@ if ActiveRecord::Base.connection.supports_migrations? | |
| 496 529 |  | 
| 497 530 | 
             
                  # TODO: set world_population >= 2**62 to cover 64-bit platforms and test
         | 
| 498 531 | 
             
                  # is_a?(Bignum)
         | 
| 499 | 
            -
                  unless current_adapter?(:IBM_DBAdapter)
         | 
| 532 | 
            +
                  unless current_adapter?(:IBM_DBAdapter) # incompatible types retrieved
         | 
| 500 533 | 
             
                    assert_kind_of Integer, b.world_population
         | 
| 501 534 | 
             
                  else
         | 
| 502 535 | 
             
                    assert_kind_of BigDecimal, b.world_population
         | 
| 503 536 | 
             
                  end
         | 
| 504 537 | 
             
                  assert_equal 6000000000, b.world_population
         | 
| 505 | 
            -
                  unless current_adapter?(:IBM_DBAdapter)
         | 
| 538 | 
            +
                  unless current_adapter?(:IBM_DBAdapter) # incompatible types retrieved
         | 
| 506 539 | 
             
                    assert_kind_of Fixnum, b.my_house_population
         | 
| 507 540 | 
             
                  else
         | 
| 508 541 | 
             
                    assert_kind_of BigDecimal, b.my_house_population
         | 
| @@ -536,7 +569,7 @@ if ActiveRecord::Base.connection.supports_migrations? | |
| 536 569 | 
             
                    assert_equal 3, b.value_of_e
         | 
| 537 570 | 
             
                  else
         | 
| 538 571 | 
             
                    # - SQL standard is an integer
         | 
| 539 | 
            -
                    unless current_adapter?(:IBM_DBAdapter)
         | 
| 572 | 
            +
                    unless current_adapter?(:IBM_DBAdapter) # incompatible types retrieved
         | 
| 540 573 | 
             
                      assert_kind_of Fixnum, b.value_of_e
         | 
| 541 574 | 
             
                    else
         | 
| 542 575 | 
             
                      assert_kind_of BigDecimal, b.value_of_e
         | 
| @@ -697,8 +730,14 @@ if ActiveRecord::Base.connection.supports_migrations? | |
| 697 730 | 
             
                  Reminder.reset_sequence_name
         | 
| 698 731 | 
             
                end
         | 
| 699 732 |  | 
| 700 | 
            -
            # | 
| 701 | 
            -
                unless current_adapter?(:FrontBaseAdapter)
         | 
| 733 | 
            +
                # FrontBase does not support default values on BLOB/CLOB columns
         | 
| 734 | 
            +
                unless current_adapter?(:FrontBaseAdapter, :IBM_DBAdapter) # incompatible default value
         | 
| 735 | 
            +
                  # zOS 9:  [IBM][CLI Driver][DB2] SQL0574N  
         | 
| 736 | 
            +
                  # DEFAULT value or IDENTITY attribute value is not valid for column \"DATA\" in table \"\".  
         | 
| 737 | 
            +
                  # Reason code: \"\".  SQLSTATE=42894 SQLCODE=-574: 
         | 
| 738 | 
            +
                  #         CREATE TABLE binary_testings (
         | 
| 739 | 
            +
                  #                id INTEGER GENERATED BY DEFAULT AS IDENTITY (START WITH 100) PRIMARY KEY, 
         | 
| 740 | 
            +
                  #                data blob DEFAULT BLOB('') NOT NULL) ">
         | 
| 702 741 | 
             
                  def test_create_table_with_binary_column
         | 
| 703 742 | 
             
                    Person.connection.drop_table :binary_testings rescue nil
         | 
| 704 743 |  | 
| @@ -716,10 +755,10 @@ if ActiveRecord::Base.connection.supports_migrations? | |
| 716 755 | 
             
                    else
         | 
| 717 756 | 
             
                      assert_equal "", data_column.default
         | 
| 718 757 | 
             
                    end
         | 
| 719 | 
            -
             | 
| 720 758 | 
             
                    Person.connection.drop_table :binary_testings rescue nil
         | 
| 721 759 | 
             
                  end
         | 
| 722 760 | 
             
                end
         | 
| 761 | 
            +
             | 
| 723 762 | 
             
                def test_migrator_with_duplicates
         | 
| 724 763 | 
             
                  assert_raises(ActiveRecord::DuplicateMigrationVersionError) do
         | 
| 725 764 | 
             
                    ActiveRecord::Migrator.migrate(File.dirname(__FILE__) + '/fixtures/migrations_with_duplicate/', nil)
         | 
    
        metadata
    CHANGED
    
    | @@ -3,8 +3,8 @@ rubygems_version: 0.9.2 | |
| 3 3 | 
             
            specification_version: 1
         | 
| 4 4 | 
             
            name: ibm_db
         | 
| 5 5 | 
             
            version: !ruby/object:Gem::Version 
         | 
| 6 | 
            -
              version: 0. | 
| 7 | 
            -
            date: 2007-04- | 
| 6 | 
            +
              version: 0.6.0
         | 
| 7 | 
            +
            date: 2007-04-30 00:00:00 -04:00
         | 
| 8 8 | 
             
            summary: "Rails Driver and Adapter for IBM Data Servers: {LUW, zOS, i5, IDS}"
         | 
| 9 9 | 
             
            require_paths: 
         | 
| 10 10 | 
             
            - lib
         | 
| @@ -73,7 +73,10 @@ files: | |
| 73 73 | 
             
            - test/migration_test.rb
         | 
| 74 74 | 
             
            - test/ibm_db_test.rb
         | 
| 75 75 | 
             
            - test/locking_test.rb
         | 
| 76 | 
            +
            - test/associations
         | 
| 77 | 
            +
            - test/associations/eager_test.rb
         | 
| 76 78 | 
             
            - test/adapter_test.rb
         | 
| 79 | 
            +
            - test/associations_test.rb
         | 
| 77 80 | 
             
            test_files: 
         | 
| 78 81 | 
             
            - test/ibm_db_test.rb
         | 
| 79 82 | 
             
            rdoc_options: []
         |