-
Notifications
You must be signed in to change notification settings - Fork 30
Prevent crash during ActiveRecord const check #328
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
Conversation
@@ -104,6 +104,17 @@ def resolve_database_info_from_model(model_name) | |||
rescue => e | |||
{ error: e.full_message(highlight: false) } | |||
end | |||
|
|||
sig { params(const: T.untyped).returns(T::Boolean) } | |||
def active_record_model?(const) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extracted out since this was getting a bit lengthy.
6f0cbb7
to
7a6887b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This happens because certain classes override the <
operator. We already handle this in Tapioca, by inverting the check
# Instead of doing
something < ActiveRecord::Base
# Use
ActiveRecord::Base > something
That should probably be enough to fix it.
7a6887b
to
435edab
Compare
435edab
to
dcbb252
Compare
dcbb252
to
55499c3
Compare
Updated based on @vinistock's suggestion, and I added a test. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Solution looks great 👍 It'd be great to have some test cases around it if the setup is not too complicated.
BTW, is |
I corrected the label.
I added a test with my update, is there something else you had in mind? |
Oh sorry I must've clicked into just a specific commit. All good then 👍 |
I'm not exactly sure how it was triggered, but I had crash for this:
I'll add a test if I'm able to reproduce.