-
-
Notifications
You must be signed in to change notification settings - Fork 810
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
Bad SQL creation from a Ransack.search object. #573
Comments
I noticed that the Arel.ast that Ransack is generating is setting the attribute value for
instead of
But I couldn't track down where this was set, so far. |
Can you please provide the information in the Contributing Guide, needed to try to reproduce your issue? Have you tried using version 1.6.6 or the master branch? |
We have to do a diff on this feature Gemlock and the master, I assume this may be a Arel issue too |
I'll try the latest from master too |
No diff !!? (We have it working fine on the other branch.) so obviously same Ransack version. As mentioned before, the Arel.ast is the first place we found the difference. Hoped you may have seen a similar occurrence. |
Not that it makes any difference but this is from ActiveAdmin, but the Params to controller don't differ. |
Log for the request, including the stacktrace.
|
Updated to 1.6.6 (from git head) |
Ok, this appears to be an issue with ActiveAdmin, closing. |
activeadmin/activeadmin#4078 (comment) May actually be a ransack issue. |
OK, so Ransack 1.6.6 and I can guess from your stack trace that you are using Ruby 2.2.2. Other than that, could you please provide the information mentioned in the Ransack Contributing Guide to try to reproduce your issue? Version of Active Record? Code? |
I've copied the relevant part of the Contributing Guide for you here: Filing an issue A bug is a demonstrable problem that is caused by the code in the repository. Good bug reports are extremely helpful! Please do not use the issue tracker for personal support requests. Guidelines for bug reports:
When filing an issue, please provide these details:
Any issue that is open for 14 days without actionable information or activity will be marked as "stalled" and then closed. Stalled issues can be re-opened if the information requested is provided. |
Code
Schema entry for users.email
Active Record version (4.2.0) |
Works for me (Ransack master, Rails master, Ruby 2.2.2, PostgreSQL 9.4.1): ∴ bin/rails console
Loading development environment (Rails 5.0.0.alpha)
[1] pry(main)> User.ransack(email_cont: "jas").result.to_sql
=> "SELECT \"users\".* FROM \"users\" WHERE (\"users\".\"email\" ILIKE '%jas%')" |
Some background informations:
I think the ActiveAdmin alias is the problem. |
Thanks @timoschilling! Closing for now until further info shows this to be in Ransack. |
Thanks @timoschilling FYI db is Postgresql |
@jonatack is there a clean way to make predicate aliases? |
Note that ActiveAdmin is configuring Ransack as follows.
|
@jasonm23 I know about that code, but it seams that it don't work in your case. |
Is 'contains' the only one not working? |
I don't know, which is working by him. The alias in ActiveAdmin exist since ~ 2 Years and we had never a problem like this. |
Unless you or others can reproduce it, it may not be a bug. |
Contains is the only one building a weird SQL statement. Equals, starts with and ends with work as expected. |
#573 (comment) note this, I would think it would be the biggest indicator of the cause? No? Why would it be generating an array instead of the ILIKE usable string? |
I don't use ActiveAdmin but a gist that allows Timo to run and reproduce On Wednesday, August 19, 2015, Timo Schilling [email protected]
|
@jasonm23 have you tried different versions of ActiveAdmin, Ransack, ActiveRecord and Postgre |
Unfortunately I cannot grant you guys access to the production app at this time. If you have any ideas, feed them to this thread. Given that adding the If I were you, I'd want to know what was going wrong. Of course if it works for me is good enough for you, so be it. |
@timoschilling as you can see at the head of this issue. I tried different versions of both ActiveAdmin and Ransack when the problem surfaced. I will put together a test app at some point, so that there's a test case. I would recommend keeping this in mind. but not to be concerned about it for now, since my app is functional with the work-around you gave me. Obviously it's not happening to many people, but personally I like to know the cause. No doubt you would also like to know where the problem lies. |
If your issue is not reproducible because you don't provide the information, it is not up to anyone else to go on a wild-goose chase of "guess what he may have done to have a problem." No one has time for that. Please respect the maintainers time. On Wednesday, August 19, 2015, JasonM23 [email protected] wrote:
|
Hi, I have a strange situation with Ransack (1.6.2)
is generating SQL:
Instead of
Any ideas why this is happening?!? Thank you!
The text was updated successfully, but these errors were encountered: