Note that there are some explanatory texts on larger screens.

plurals
  1. POIs this a possible bug in 'activerecord-jdbc-adapter' when trying to eager load?
    text
    copied!<p>We have the following model:</p> <p><strong>payment.rb:</strong></p> <pre><code>class Payment &lt; ActiveRecord::Base has_many :currencies default_scope :include =&gt; :currencies end </code></pre> <p>We are using <code>default_scope</code> to eager load the currencies. When we run this we get the following error:</p> <pre><code>[2012-03-22 21:43:25] ERROR NoMethodError: undefined method `each' for nil:NilClass /home/me/.rvm/gems/jruby-1.6.7@my_project/gems/activerecord-3.2.1/lib/active_record/associations/preloader/association.rb:88:in `associated_records_by_owner' org/jruby/RubyArray.java:1615:in `each' /home/me/.rvm/gems/jruby-1.6.7@my_project/gems/activerecord-3.2.1/lib/active_record/associations/preloader/association.rb:85:in `associated_records_by_owner' ... </code></pre> <p>The problem can be found in:</p> <p><strong>Line 88 and 89 in <a href="https://github.com/rails/rails/blob/v3.2.1/activerecord/lib/active_record/associations/preloader/association.rb" rel="nofollow">association.rb (github link)</a>:</strong></p> <pre><code>... owner_key = record[association_key_name].to_s owners_map[owner_key].each do |owner| ... </code></pre> <p><br/> When I step through the code I can see that <code>record[association_key_name]</code> is a BigDecimal e.g. 108.0, and when <code>to_s</code> is applied it becomes "108.0". However, the keys in the <code>owners_map</code> hash is expecting "108" not "108.0"</p> <p>The <code>association_key_name</code> is the name of the foreign key in the Oracle database and is defined as type Number. The primary key is also defined as type Number, but strangely enough it doesn't resolve to a BigDecimal.</p> <p>Any ideas? Is this a possible bug? Or does the precision on the database column need altered?</p> <p><strong>System Info:</strong><br/> JRuby on Rails (3.2.1)<br/> ActiveRecord JDBC Adapter<br/> Oracle Database (using views instead of tables)<br/></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload