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

Check type before sending #value message to predicate #1468

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

spaghetticode
Copy link

Closes #1467

The previous implementation was giving for granted that every predicate respond to #value, which doesn't seem to be the case at least when having a Arel::SelectManager.

by simply inverting the terms of the existing AND check we can fix the issue without introducing unknown side effects.

spaghetticode added a commit to peterberkenbosch/solidus that referenced this pull request Dec 15, 2023
Issue: activerecord-hackery/ransack#1467
PR: activerecord-hackery/ransack#1468

Hopefully the PR will be merged soon so we can remove this patch.
@spaghetticode
Copy link
Author

Interestingly, CI is not running on the PR 🤷

elia pushed a commit to peterberkenbosch/solidus that referenced this pull request Dec 20, 2023
Issue: activerecord-hackery/ransack#1467
PR: activerecord-hackery/ransack#1468

Hopefully the PR will be merged soon so we can remove this patch.
elia pushed a commit to peterberkenbosch/solidus that referenced this pull request Dec 20, 2023
Issue: activerecord-hackery/ransack#1467
PR: activerecord-hackery/ransack#1468

Hopefully the PR will be merged soon so we can remove this patch.
@scarroll32
Copy link
Member

Interestingly, CI is not running on the PR 🤷

Needs to be approved for the 1st run.

@scarroll32
Copy link
Member

@spaghetticode could you please add a test for this change?

The previous implementation was giving for granted that every predicate
respond  to `#value`, but that doesn't seem to be the case at least when
having a `Arel::SelectManager`.

by simply inverting the terms of the existing AND check we can fix the issue
without introducing unknown side effects.

In order to test the change, a new ransacker has been added to the Person model.
@spaghetticode
Copy link
Author

@scarroll32 I've just added a test that fails without the change.

The method I modified is private, so it needs to be tested indirectly. I followed the existing examples, but I had to add a new ransacker to the Person model, I hope it makes sense. Please let me know if it works for you, thanks!

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

Successfully merging this pull request may close these issues.

NoMethodError: undefined method `value' for #<Arel::SelectManager
2 participants