Project

General

Profile

Bug #1181

Host searching returns duplicates (or-ed facts)

Added by Tim Speetjens almost 8 years ago. Updated almost 8 years ago.

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

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"

Associated revisions

Revision 5909d4d9 (diff)
Added by Ohad Levy almost 8 years ago

fixes #1181 - Host searching returns duplicates

History

#1 Updated by Ohad Levy almost 8 years ago

  • Category set to Search
  • Assignee set to Amos Benari
  • Target version deleted (0.4)

#2 Updated by Tim Speetjens almost 8 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.

#3 Updated by Ohad Levy almost 8 years ago

  • Target version set to 0.4

#4 Updated by Ohad Levy almost 8 years ago

  • Status changed from New to Closed
  • % Done changed from 0 to 100

Also available in: Atom PDF