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

Fixes #23234 - Simplify parent scope lookup #7289

Merged
merged 1 commit into from
Jan 2, 2020

Conversation

tbrisker
Copy link
Member

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.

@theforeman-bot
Copy link
Member

Issues: #23234

lib/core_extensions.rb Outdated Show resolved Hide resolved
@mmoll
Copy link
Contributor

mmoll commented Dec 25, 2019

Let's drop Ruby 2.3 for develop first, I'd say...

@mmoll
Copy link
Contributor

mmoll commented Dec 25, 2019

Should be dropped now, please remove the Ruby 2.3 compatibility code. ✨

@mmoll
Copy link
Contributor

mmoll commented Dec 25, 2019

[test katello]

@mmoll
Copy link
Contributor

mmoll commented Dec 26, 2019

katello test failure maybe related? 🤔

@tbrisker
Copy link
Member Author

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.
@tbrisker
Copy link
Member Author

Hope this will fix the failing katello test, looks like in some cases the id can be nil, added handling for them.
@ShimShtein - since you wrote most of the original code, might interest you to take a look at this change, you probably don't remember the context since it was so long ago but hopefully i'm not missing something here.

@mmoll mmoll merged commit 5fb5603 into theforeman:develop Jan 2, 2020
@mmoll
Copy link
Contributor

mmoll commented Jan 2, 2020

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?
Copy link
Member

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'.

Copy link
Member Author

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?
Copy link
Member

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

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants