rails/rails — pull request #11082 by senny (2013-06-25 08:21:29+00:00)
Title: fix preloading of has_many :through associations with STI

This bug only occured when preloading a has_many :through association,
targeting a STI class, which is no direct descendent of `ActiveRecord::Base`.

This triggered `finder_needs_type_condition?`, which resulted in an
illegal where condition in the preloader:

```
ActiveRecord::StatementInvalid: SQLite3::SQLException:
no such column: posts.type: SELECT "users".* FROM "users"
WHERE "posts"."type" IN ('Article')
```

This patch removes all the where values from preloading that are present
on the `#unscoped` relation.

Closes #11078