Skip to content
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

Ransack trims trailing whitespaces. #1222

Closed
omaik opened this issue Apr 26, 2021 · 1 comment
Closed

Ransack trims trailing whitespaces. #1222

omaik opened this issue Apr 26, 2021 · 1 comment

Comments

@omaik
Copy link

omaik commented Apr 26, 2021

Hey, could you please advise me whether this expected behavior or not, and what the intention behind it. Thanks.

See example.

[4] pry(main)> Quote.ransack(error_details_eq: 'abc  ').result.to_sql
=> "SELECT \"quotes\".* FROM \"quotes\" WHERE \"quotes\".\"error_details\" = 'abc'"
[5] pry(main)> Quote.where(error_details: 'abc   ').to_sql
=> "SELECT \"quotes\".* FROM \"quotes\" WHERE \"quotes\".\"error_details\" = 'abc   '"

and btw, thanks for an awesome gem and the work you do here ❤️

@deivid-rodriguez
Copy link
Contributor

We started doing this at #1126, and while the default is now to strip whitespace, a way to opt-out was added at #1214.

So, to keep the original string use

Ransack.configure do |c|
  # Change whitespace stripping behaviour.
  # Default is true
  c.strip_whitespace = false
end

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

No branches or pull requests

2 participants