Project

General

Profile

Refactor #29710

Change false where conditions to `none`

Added by Tomer Brisker almost 3 years ago. Updated over 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Database
Target version:
-
Difficulty:
Triaged:
No
Bugzilla link:
Fixed in Releases:
Found in Releases:
Red Hat JIRA:

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

Related to Foreman - Bug #31538: Each smart class parameter appears twice, when having two environmentsClosed

Associated revisions

Revision cd4b1820 (diff)
Added by Tomer Brisker over 2 years ago

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.

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

#4 Updated by Tomer Brisker over 2 years ago

  • Related to Bug #31538: Each smart class parameter appears twice, when having two environments added

Also available in: Atom PDF