Regression in polymorphic associations
This issue only affects Active Record 5.2.
In Active Record < 5.2, polymorphic joins will include a condition on the _type column.
LEFT OUTER JOIN "people"
ON "people"."id" = "notes"."notable_id" AND "notes"."notable_type" = 'Person'
In Active Record 5.2, the condition will not be included:
LEFT OUTER JOIN "people"
ON "people"."id" = "notes"."notable_id"
Thanks for the issue @rzane, are you seeing issues under Rails 5.2 with this? The old SQL should continue to work, shouldn't it?
Yeah, this issue only affects Active Record 5.2. In 5.2, the query will be missing the AND "notes"."notable_type" = 'Person' bit, which is very important for polymorphic associations.
This is definitely an issue, because imagine how that query might behave if the notable table looked like this:
| id | notable_id | notable_type |
|---|---|---|
| 1 | 99 | Dog |
| 2 | 99 | Person |
@seanfcarroll any chance of having this issue fixed sometime soon? Currently this is the only issue that prevents me from upgrading my project to Rails 5.2. Thanks.
@octavpo You should use Ransack 2 which is not using polyamorous anymore and supports Rails 5.2