Refactor #29710
Change false where conditions to `none`
Description
There are multiple places where we use conditions like "where(1=0)" or "where(id<0)" etc. because we want to preserve the active relation object. Since Rails 4 there is `none` method that achieves the same goal with null object pattern, so the eventual query won't even be sent to the DB - https://api.rubyonrails.org/classes/ActiveRecord/QueryMethods.html#method-i-none
Related issues
Associated revisions
History
#1
Updated by The Foreman Bot almost 3 years ago
- Assignee set to Tomer Brisker
- Status changed from New to Ready For Testing
- Pull request https://github.com/theforeman/foreman/pull/7641 added
#2
Updated by The Foreman Bot over 2 years ago
- Fixed in Releases 2.3.0 added
#3
Updated by Tomer Brisker over 2 years ago
- Status changed from Ready For Testing to Closed
Applied in changeset foreman|cd4b1820bd38e888500f2b2f31b65f22857ade5e.
#4
Updated by Tomer Brisker over 2 years ago
- Related to Bug #31538: Each smart class parameter appears twice, when having two environments added
Fixes #29710 - Clean up .where conditions
Using methods such as `none`, `not`, `or`, or `all`, we can simplify
some `.where` calls in ways that weren't possible in some very old rails
versions.