-
Notifications
You must be signed in to change notification settings - Fork 987
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
Fixes #23234 - Simplify parent scope lookup #7289
Conversation
Issues: #23234 |
e7da081
to
2f3d5a5
Compare
Let's drop Ruby 2.3 for develop first, I'd say... |
Should be dropped now, please remove the Ruby 2.3 compatibility code. ✨ |
[test katello] |
katello test failure maybe related? 🤔 |
seems to be consistently failing on the same test, so i assume it is related. will try to dig in. |
Knowing the id format allows us to know which field we should search by, no need to try both id and friendly_id and use conditional order to pick the friendly id first.
Hope this will fix the failing katello test, looks like in some cases the id can be nil, added handling for them. |
merged, thanks @tbrisker! |
|
||
filtered_scope = base_scope.where(arel_query) | ||
# The id is an integer - no need to check more complex options, just scope by it | ||
return base_scope.where(id: resource_id) if resource_id.integer? |
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.
I think this will miss records with name set to an integer - '123'
.
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.
Good point, opened #7328 to fix this case.
@@ -189,12 +189,26 @@ def truncate_bytes(truncate_at, omission: "…") | |||
end | |||
end | |||
end | |||
|
|||
def integer? |
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.
Instead of extending core object, we can use
foo.to_i.to_s == foo.to_s
Knowing the id format allows us to know which field we should search by,
no need to try both id and friendly_id and use conditional order to
pick the friendly id first.