Project

General

Profile

Bug #4314

unable to filter on classes

Added by Adam Winberg over 5 years ago. Updated 12 months ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Search
Target version:
Difficulty:
Triaged:
Bugzilla link:
Pull request:
Team Backlog:
Fixed in Releases:
Found in Releases:

Description

After update to 1.4.0 I can no longer filter host lists based on classes. Regardless of which class i try to filter with, theforeman returns all hosts as a result.

Example of query:
/hosts?search=class=cacti

should return one host but returns all hosts.

Associated revisions

Revision a44dd094 (diff)
Added by Dominic Cleal over 5 years ago

fixes #4314 - ignore default scope ordering on host search by puppet class

Revision f96d1ded (diff)
Added by Dominic Cleal over 5 years ago

fixes #4314 - ignore default scope ordering on host search by puppet class

(cherry picked from commit a44dd0943b5ccc2c2e9a0ce264e4b2f38b5edd4d)

Conflicts:
app/models/concerns/hostext/search.rb

History

#1 Updated by Dominic Cleal over 5 years ago

  • Project changed from Hammer CLI to Foreman
  • Category changed from Foreman commands (obsolete) to Search

#2 Updated by Adam Winberg over 5 years ago

Got this from production.log in debug mode:

Hostgroup Load (0.6ms)  SELECT DISTINCT hostgroups.id FROM "hostgroups" INNER JOIN "hostgroup_classes" ON "hostgroup_classes"."hostgroup_id" = "hostgroups"."id" INNER JOIN "puppetclasses" ON "puppetclasses"."id" = "hostgroup_classes"."puppetclass_id" WHERE (puppetclasses.name = 'foreman') ORDER BY hostgroups.label
PGError: ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list
LINE 1: ..." WHERE (puppetclasses.name = 'foreman') ORDER BY hostgroups...

The PGError indicates there is something wrong with the query. Adjusting the query to include 'hostgroups.label' in the SELECT gets rid of this error, dont know where in the source this is set though.

#3 Updated by Adam Winberg over 5 years ago

changing row 34 in app/models/hostgroup.rb from

order("hostgroups.label")

to

order("hostgroups.id")

fixes the problem. But does it introduce other problems?

#4 Updated by Dominic Cleal over 5 years ago

It'd mean the sorting of the host groups in the main list is by their numerical IDs rather than their names. We changed to this a while ago in #3107 for improved usability.

#5 Updated by Dominic Cleal over 5 years ago

  • Status changed from New to Assigned
  • Assignee set to Dominic Cleal
  • Target version set to 1.9.0
  • Legacy Backlogs Release (now unused) set to 7

#6 Updated by Dominic Cleal over 5 years ago

  • Status changed from Assigned to Ready For Testing

#7 Updated by Dominic Cleal over 5 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100

Also available in: Atom PDF