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

Update Active Record find sig to allow a block #1844

Merged
merged 2 commits into from
Apr 8, 2024

Conversation

bdewater
Copy link
Contributor

@bdewater bdewater commented Mar 26, 2024

Motivation

While upgrading our app since working on #1799 I came across code that looks like Model.where(condition: true).find { |m| m.computed_attribute == "foo" } and this doesn't fit the signatures generated. While replacing find with detect was an easy enough workaround, here's the proper fix.

Tests

Updated existing tests.

TypeParam accepts a default, which is confusing since it's not used in
sigs. SigParam is the right thing to use here, and create_sig will
build these from a hash.
@bdewater
Copy link
Contributor Author

bdewater commented Apr 4, 2024

Rebased this on top of #1856 since that has breaking changes.

With a block it behaves like Enumerable#find
Copy link

@rzaharenkov rzaharenkov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not the code owner but hit the same issue and would appreciate if this PR is shipped. Thank you!

@KaanOzkan KaanOzkan added the enhancement New feature or request label Apr 8, 2024
@KaanOzkan KaanOzkan merged commit 46911cf into Shopify:main Apr 8, 2024
19 of 20 checks passed
@bdewater bdewater deleted the ar-find-block branch April 9, 2024 22:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants