Bug #9398
closedInvalid MySQL query after login on 1.7.x
Description
For users with special roles, directly after login, this error appears:
Mysql2::Error: Unknown column 'hostgroups.title' in 'where clause': SELECT COUNT FROM (SELECT `reports`.`id` AS count_column FROM `reports` LEFT OUTER JOIN `hosts` ON `hosts`.`id` = `reports`.`host_id` AND `hosts`.`type` IN ('Host::Managed') WHERE `reports`.`host_id` IN (SELECT `hosts`.`id` FROM `hosts` WHERE `hosts`.`organization_id` IN (2) AND `hosts`.`type` IN ('Host::Managed') AND ((((`hostgroups`.`title` LIKE 'Group%') AND (`hosts`.`organization_id` = '2')) OR (`hostgroups`.`name` = BINARY 'Group1') OR (`hostgroups`.`name` = BINARY 'Group2'))) ORDER BY `hosts`.`name` ASC) AND (status <> 0) AND ((`reports`.`reported_at` >= '2015-02-10')) LIMIT 6) subquery_for_count
The subquery:
SELECT `hosts`.`id` FROM `hosts` WHERE `hosts`.`organization_id` IN (2) AND `hosts`.`type` IN ('Host::Managed') AND ((((`hostgroups`.`title` LIKE 'Group%') AND (`hosts`.`organization_id` = '2')) OR (`hostgroups`.`name` = BINARY 'Group1') OR (`hostgroups`.`name` = BINARY 'Group2'))) ORDER BY `hosts`.`name` ASC
does not join in the hostgroups table, requests columns from it though.
Updated by Dominic Cleal almost 10 years ago
- Is duplicate of Bug #8817: PGError: ERROR: missing FROM-clause entry for table "hostgroups" added
Updated by Dominic Cleal almost 10 years ago
- Status changed from New to Duplicate
Thanks, tracked under #8817.