Forums | Admin

Discussion Forums: open-discussion

Start New Thread Start New Thread
Message: 96744
BY: Zach Pratt (zachwiu)
DATE: 2011-07-07 16:12
SUBJECT: issue with ibm_db gem and db2 on z/OS

 

We're running version 8 of db2 for z/OS. The version string returned from db2 is 8.1.5. We're also using version 2.5.6 of the gem. Our problem appears to be in the active record adapter and what it expects to be returned from the driver. When querying a table using the where method of activerecord, we get the following stack trace:

RuntimeError: An unexpected error occurred during retrieval of column metadata: undefined method `downcase' for nil:NilClass
from /usr/lib64/ruby/gems/1.8/gems/ibm_db-2.5.6/lib/active_record/connection_adapters/ibm_db_adapter.rb:1569:in `columns'
from /usr/lib64/ruby/gems/1.8/gems/activerecord-3.0.4/lib/active_record/base.rb:679:in `columns'
from /usr/lib64/ruby/gems/1.8/gems/activerecord-3.0.4/lib/active_record/base.rb:692:in `column_names'
from /usr/lib64/ruby/gems/1.8/gems/activerecord-3.0.4/lib/active_record/base.rb:1665:in `inspect'
from /usr/lib64/ruby/gems/1.8/gems/activerecord-3.0.4/lib/active_record/relation.rb:356:in `inspect'
from /usr/lib64/ruby/1.8/irb.rb:302:in `output_value'
from /usr/lib64/ruby/1.8/irb.rb:151:in `eval_input'
from /usr/lib64/ruby/1.8/irb.rb:263:in `signal_status'
from /usr/lib64/ruby/1.8/irb.rb:147:in `eval_input'
from /usr/lib64/ruby/1.8/irb.rb:146:in `eval_input'
from /usr/lib64/ruby/1.8/irb.rb:70:in `start'
from /usr/lib64/ruby/1.8/irb.rb:69:in `catch'
from /usr/lib64/ruby/1.8/irb.rb:69:in `start'
from /usr/lib64/ruby/gems/1.8/gems/railties-3.0.4/lib/rails/commands/console.rb:44:in `start'
from /usr/lib64/ruby/gems/1.8/gems/railties-3.0.4/lib/rails/commands/console.rb:8:in `start'
from /usr/lib64/ruby/gems/1.8/gems/railties-3.0.4/lib/rails/commands.rb:23
from script/rails:6:in `require'

I have tested this with rails 3.0.4, 3.0.7 and 3.0.9 and the problem is the same with each.

The problem appears to be on line 1522 in the ibm_db_adapter.rb where it's calling the fetch_assoc method of the IBM_DB class. The adapter expects an associative array to be returned with keys like "column_name" , however, the keys that are returned are actually numerical.

For example, we have a table named PROSPECTIVE_STUDENT which we have mapped to an activerecord model named ProspectiveStudent. The primary key of the table is student_id and when we make the following method call:

ProspectiveStudent.where(:student_id => '777777777')

The result of IBM_DB.fetch_assoc(stmt) is:

{"11"=>0, "6"=>"CHAR", "12"=>"", "7"=>9, "13"=>nil, "8"=>9, "14"=>1, "9"=>nil, "15"=>nil, "16"=>9, "17"=>1, "1"=>nil, "18"=>"NO", "2"=>"STU", "3"=>"PROSPECTIVE_STUDENT", "10"=>nil, "4"=>"STUDENT_ID", "5"=>1}

Any ideas?

Thanks in advance.


Thread View

Thread Author Date
issue with ibm_db gem and db2 on z/OSZach Pratt2011-07-07 16:12
      RE: issue with ibm_db gem and db2 on z/OSPraveen Devarao2011-07-07 18:11
            RE: issue with ibm_db gem and db2 on z/OSZach Pratt2011-07-07 18:32
                  RE: issue with ibm_db gem and db2 on z/OSZach Pratt2011-07-07 19:08
                        RE: issue with ibm_db gem and db2 on z/OSZach Pratt2011-07-25 20:39

Post a followup to this message