view · edit · sidebar · attach · print · history

dbi 0.4.5 gem changes Ruby 1.9.1 to Ruby 1.9.2

<< CharacterEncodings | Index | Gd2 >>

Hash iteration breaks in Ruby 1.9.2

The Ruby dbi gem's Hash-Iteration breaks with Ruby 1.9.2. 1.9.1 did work. This is the fix of Chuck Remes. Thank you Chuck:


change these lines

 - h.each_key do |k|
 + h.keys.each do |k|

also see

Force the Array - works for Ruby 1.9.1 and Ruby 1.9.2

So in


we changed




and it works! But we do not yet understand why it works for Ruby 1.9.2

How did we reach the conclusion

Why did I add 'to_a' method? (thought flow)

    * When I looked at the 'row' by 'p' method, it looked like an Array
    * I checked 'row' class by writing 'p row.class' then it showed 'DBI::Row'
    * I checked DBI::Row definition (/usr/lib64/ruby/gems/1.9.1/gems/dbi-0.4.5/lib/dbi/row.rb)
    * There is 'to_a' method defined
    * Also see: 


  • DBI::Row#@arr (Array) instannce is created around line:46-52 of /usr/lib64/ruby/gems/1.9.1/gems/dbi-0.4.5/lib/dbi/row.rb (DBI::Row class)
  • Somehow Ruby 1.9.1 creates a new Array instance but Ruby 1.9.2 does not create a new Array instance
view · edit · sidebar · attach · print · history
Page last modified on March 22, 2011, at 04:45 PM