rails/rails — pull request #13929 by Recca (2014-02-03 09:04:06+00:00)
Title: Always preload included polymorphic associations

Always preload included polymorphic associations while using `eager_load` or `references`

Before:
```ruby
Tagging.includes(:taggable, :tag).references(:tag).where(tags: {id: 1})
#This raise ActiveRecord::EagerLoadPolymorphicError: Can not eagerly load the polymorphic association :taggable
```
After:
```ruby
Tagging.includes(:taggable, :tag).references(:tag).where(tags: {id: 1})
##load taggable with tag
#SELECT "taggings"."id" AS t0_r0, "taggings"."tag_id" AS t0_r1, "taggings"."super_tag_id" AS t0_r2, "taggings"."taggable_id" AS t0_r3, "taggings"."taggable_type", "tags"."id" AS t1_r0, "tags"."name" AS t1_r FROM "taggings" LEFT OUTER JOIN "tags" ON "tags"."id" = "taggings"."tag_id" WHERE "tags"."id" = 1
##load the polymorphic :
#Post Load (x ms) SELECT "posts".* FROM "posts" WHERE "posts"."id" IN (1, 2)
#FakeModel Load (x ms) SELECT "fake_models".* FROM "fake_models" WHERE "fake_models"."id" IN (1)
#Item Load (x ms) SELECT "items".* FROM "items" WHERE "items"."id" IN (1)
```