-
Notifications
You must be signed in to change notification settings - Fork 21.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ActiveRecord's .where
cannot handle polymorphic arrays containing different types
#17011
Comments
I have a patch together for this issue, but I'm waiting to submit it since it relies in part on #17010. |
This issue has been automatically marked as stale because it has not been commented on for at least The resources of the Rails team are limited, and so we are asking for your help. If you can still reproduce this error on the Thank you for all your contributions. |
I and others am having issues that appear to be stemming from this, as discussed in spree/spree#6213 |
Should have looked here first, but I also worked on this: Not sure if my work is helpful to you @phuibonhoa but I figured I'd put it here/bump this issue anyway. |
Example: https://gist.github.com/pvande/2e346213ace076cd0edb
ActiveRecord supports filtering on a polymorphic association, including filtering on an array of related objects, permitting users to write queries like this:
This generally works pretty well, generating an SQL query like this:
When attempting such a query with multiple related types however, the query breaks down.
The expected result for the above query would include all Treasure looted by either
Parrot#1
orPirate#1
.The text was updated successfully, but these errors were encountered: