Bug #1181
closedHost searching returns duplicates (or-ed facts)
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"
Updated by Ohad Levy about 13 years ago
- Category set to Search
- Assignee set to Amos Benari
- Target version deleted (
0.4)
Updated by Tim Speetjens about 13 years ago
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.
Updated by Ohad Levy about 13 years ago
- Status changed from New to Closed
- % Done changed from 0 to 100
Applied in changeset 5909d4d9bb73527eed8f414c76744b08170a28f8.