Bug #4314
closed
unable to filter on classes
Added by Adam Winberg almost 11 years ago.
Updated over 6 years ago.
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.
- Project changed from Hammer CLI to Foreman
- Category changed from Foreman commands (obsolete) to Search
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.
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?
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.
- Status changed from New to Assigned
- Assignee set to Dominic Cleal
- Target version set to 1.9.0
- Translation missing: en.field_release set to 7
- Status changed from Assigned to Ready For Testing
- Status changed from Ready For Testing to Closed
- % Done changed from 0 to 100
Also available in: Atom
PDF