Project

General

Profile

« Previous | Next » 

Revision 26678da1

Added by John Mitsch almost 8 years ago

Fixes #15050 - Scoped search hostname w/o field no longer ISEs

Searching for an existing host's name without any fields
specified results in an SQL error:
missing FROM-clause entry for
table \"organizations_hosts\"

This can be reproduced using
curl -X GET -u admin 'http://localhost:3000/api/v2/
hosts?organization_id=2&search=<hostname>'

where <hostname> is an existing hostname

setting this field to explicit_only will fix the issue

My perspective of what the larger issue is:
This has to do with scoped search using AR's includes1
which generates a sql query with a non-existing table,
organization_hosts

This is shown on the command line

Host.includes([:location, :organization])
.where("taxonomies.name" => "org1")
.to_sql.include?("organizations_hosts")
evaluates to true

I am not sure about what to do for a more permanent fix,
it looks like its the same issue as
https://github.com/theforeman/foreman/commit/
5185335248abd0104ec0b791df5e641eeae9da6b

(cherry picked from commit b9a3e39d0a62b1eda43b6ce8da54b636c1500e58)

  • added
  • modified
  • copied
  • renamed
  • deleted