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

Are there any plans to support ActiveRecord .find_by_xxx? #2206

Open
pvcresin opened this issue Feb 20, 2025 · 2 comments
Open

Are there any plans to support ActiveRecord .find_by_xxx? #2206

pvcresin opened this issue Feb 20, 2025 · 2 comments

Comments

@pvcresin
Copy link

If I understand correctly, I think it is currently as follows

# NG
Article.find_by_id(target_id) # -> error: find_by_id not found

# OK
Article.find_by(id: target_id) # -> no error

I would like Tapioca to support the generation of .find_by_xxx.

Do you have plans to do so?

@KaanOzkan
Copy link
Contributor

I think they are implemented here. We know the attribute names so we could do it in ActiveModelAttributes compiler. But I don't know why they aren't defined together with the attributes themselves, maybe there's a potential blocker there, cc @paracycle.

@pvcresin
Copy link
Author

@KaanOzkan Thank you for sharing the details.
I guessed that generating the type for the .find_by_x method would affect the performance of the type checking because of the large size of the RBI definition.

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