-
-
Notifications
You must be signed in to change notification settings - Fork 787
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
Rails 5 IN-clause subquery #702
Comments
Reproduced. On Rails 5.0.0 and master (5.1.0.alpha) too. |
With both Ransack 1.8.1 (latest release) and also 1.7.0 from a year ago. |
@jaredbeck This appears to be coming from a change in Arel or Active Record between Rails 4 and 5, not a bug in Ransack. It's a bit of a strange example. You might need to formulate your Arel query differently. Ransackers just provide a conduit to Arel. The Rails team has clarified over the past couple years that Arel methods are P.S. - This works fine, though I imagine you are trying to do something else: Post.ransack(title_in: 'banana').result |
Correct, my admittedly contrived example does not require an IN-clause subquery. My app does.
Yeah, my colleagues keep writing complicated custom ransackers that break every time I upgrade arel. Maybe there should be a warning about this in the custom ransacker docs. Would you like a PR with such a warning? |
There might be news from the front. If I recall @sgrif's remarks in the latest http://bikeshed.fm/74 podcast discussing Ransack and Arel -- and I could be wrong -- the Arel API is planned to stabilize and return from PR proposal: There is already a warning in the ransackers section of the wiki about complicated Arel ransackers not being a cure-all with mention of a few alternate solutions, so I think we're fine. On the other hand, any of the TODO or FIXME comments in the code base would be wonderful PRs to work on. On Monday, August 8, 2016, Jared Beck notifications@github.com wrote:
|
🎺 🎵📰! 😀
That's great news, thanks. |
ransack 1.8.0: In rails 4, it is possible to use a
SqlLiteral
node as theformatter
of a customransacker
. In rails 5 it is not. There may be an issue with rails 5's new attribute type system.Consider this contrived, yet complete and executable example. The
formatter
is a subquery ofPost
ids.I know there are better ways to use ransack to search post titles :) as I said, this is a contrived example.
The text was updated successfully, but these errors were encountered: