This project is archived and is in readonly mode.
Query built wrong for preloading associations nested under polymorphic belongs_to
-
Maxim Chernyak
Still happens on 2.3.5 with ruby 1.8
-
Maxim Chernyak
- Tag changed from 2.3.4, polymorphic, preload, sql to 2.3.x, patch, polymorphic, preload, sql, test
Here's a patch with a test for this, for rails 2-3-stable. This is probably irrelevant to Rails3.
-
Maxim Chernyak
I should probably clarify that this is a patch with both a test and a fix. Not just test.
-
José Valim
Applied patch for 2-3-stable. Can someone please investigate if this is an issue in Rails 3 or not?
-
Repository
- State changed from new to resolved
(from [844da12ba6acfb71a691ba32901d7acf4cbe37b4]) Fix eager loading of polymorphic has_one associations nested-included under polymorphic belongs_to associations. [#3233 Query built wrong for preloading associations nested under polymorphic belong... state:resolved]
Signed-off-by: José Valim jose.valim@gmail.com
http://github.com/rails/rails/commit/844da12ba6acfb71a691ba32901d7a... -
Neeraj Singh
@Maxim looks like rails3 is not behaving as expected. Can you verify that?
def self.lab1 puts Subscription.all.inject([]) { |n, s| n + s.subscribable.notifications } end def self.lab2 puts Subscription.all(:include => {:subscribable => :notifications}).inject([]) { |n, s| n + s.subscribable.notifications } endI am getting three records with lab1 and two records with lab2.
