Hey all, I''d really appreciate some eyes on https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/5845-activerecord-3-eager-loading-fail#ticket-5845-19. There''s a small issue in Rails 3 eager loading, and this ticket has an accompanying patch. Sssociations that show up twice in a Relation chain like: Article.includes(:comments).includes(:comments => :moderations) will show up twice in the JoinDependency''s join_parts but only once in the query that gets run. This wreaks all kinds of fun havoc with the select statement that gets used in construct_relation_for_association_find, since it will try to select from both copies of the table. One solution (the one I implemented in the patch) is to ensure that the JoinDependency only joins each association once. This seems to be in keeping with the intended functionality, based on includes_values being "uniq"ed elsewhere. Naturally, a uniq won''t catch a situation as described above, since includes_values contains a symbol, :comments, and a hash, {:comments => :moderations}. Thanks in advance! -- Ernie Miller http://metautonomo.us http://github.com/ernie http://twitter.com/erniemiller -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
On Mon, Oct 25, 2010 at 11:44:38AM -0400, Ernie Miller wrote:> Hey all, > > I''d really appreciate some eyes on https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/5845-activerecord-3-eager-loading-fail#ticket-5845-19. There''s a small issue in Rails 3 eager loading, and this ticket has an accompanying patch. > > Sssociations that show up twice in a Relation chain like: > > Article.includes(:comments).includes(:comments => :moderations) > > will show up twice in the JoinDependency''s join_parts but only once in the query that gets run. This wreaks all kinds of fun havoc with the select statement that gets used in construct_relation_for_association_find, since it will try to select from both copies of the table. > > One solution (the one I implemented in the patch) is to ensure that the JoinDependency only joins each association once. This seems to be in keeping with the intended functionality, based on includes_values being "uniq"ed elsewhere. Naturally, a uniq won''t catch a situation as described above, since includes_values contains a symbol, :comments, and a hash, {:comments => :moderations}. > > Thanks in advance!Hey Ernie, I''ll take a look in the next few days. :-) -- Aaron Patterson http://tenderlovemaking.com/