Bug #1181
closed
Host searching returns duplicates (or-ed facts)
Added by Tim Speetjens about 13 years ago.
Updated about 13 years ago.
Description
When filtering hosts, based on facts or-ed criteria return duplicates:
Affected:
facts.operatingsystemrelease = 5.3 or facts.operatingsystemrelease = 5.4
facts.clientversion = 0.25.5 or facts.hardwaremodel = <model>
Correct:
model = "Model 1" or model = "Model 2"
- Category set to Search
- Assignee set to Amos Benari
- Target version deleted (
0.4)
A quick look in dev mode reveals the following SQL (mysql):
SELECT `hosts`.* FROM `hosts`
INNER JOIN `fact_values` fact_values_730703 ON (hosts.id = fact_values_730703.host_id)
INNER JOIN `fact_names` fact_names_730703 ON (fact_names_730703.id = fact_values_730703.fact_name_id)
INNER JOIN `fact_values` fact_values_804546 ON (hosts.id = fact_values_804546.host_id)
INNER JOIN `fact_names` fact_names_804546 ON (fact_names_804546.id = fact_values_804546.fact_name_id) WHERE ((fact_names_730703.`name` = 'operatingsystemrelease' AND fact_values_730703.`value` = BINARY '5.3') OR (fact_names_804546.`name` = 'operatingsystemrelease' AND fact_values_804546.`value` = BINARY '5.4')) ORDER BY `hosts`.`name` ASC LIMIT 0, 20
This should be:
SELECT `hosts`.* FROM `hosts`
INNER JOIN `fact_values` fact_values_730703 ON (hosts.id = fact_values_730703.host_id)
INNER JOIN `fact_names` fact_names_730703 ON (fact_names_730703.id = fact_values_730703.fact_name_id)
INNER JOIN `fact_values` fact_values_804546 ON (hosts.id = fact_values_804546.host_id)
INNER JOIN `fact_names` fact_names_804546 ON (fact_names_804546.id = fact_values_804546.fact_name_id)
WHERE
fact_names_730703.`name` = 'operatingsystemrelease'
AND
fact_names_804546.`name` = 'operatingsystemrelease'
AND
( fact_values_730703.`value` = BINARY '5.3' OR fact_values_804546.`value` = BINARY '5.4')
ORDER BY `hosts`.`name` ASC LIMIT 0, 20
This same principle applies for different fact names, as in the second example query.
- Target version set to 0.4
- Status changed from New to Closed
- % Done changed from 0 to 100
Also available in: Atom
PDF