Skip to content
This repository has been archived by the owner on Nov 12, 2019. It is now read-only.

Regression in polymorphic associations #37

Open
rzane opened this issue Mar 30, 2018 · 4 comments
Open

Regression in polymorphic associations #37

rzane opened this issue Mar 30, 2018 · 4 comments

Comments

@rzane
Copy link

rzane commented Mar 30, 2018

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"
@scarroll32
Copy link
Member

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?

@rzane
Copy link
Author

rzane commented Apr 14, 2018

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

@octavpo
Copy link

octavpo commented May 3, 2018

@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.

@gregmolnar
Copy link
Member

@octavpo You should use Ransack 2 which is not using polyamorous anymore and supports Rails 5.2

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants