Project

General

Profile

Bug #12194

Can't search for multiple facts in foreman 1.10.0-RC1

Added by Timo Goebel over 4 years ago. Updated over 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Search
Target version:
Difficulty:
Triaged:
Bugzilla link:
Fixed in Releases:
Found in Releases:

Description

Foeman 1.10.0 introduced a bug, that you can't search for multiple facts in the host overview (both via gui and api)

A search query like "facts.app_tier = prod and facts.project = abc" shows no results in 1.10, though there were a lot of results in 1.9.2.
Searching for "facts.app_tier = prod or facts.project = abc" works though.


Related issues

Related to Foreman - Feature #11150: Allow searching of facts as types other than stringClosed2015-07-19

Associated revisions

Revision 57e9d8a3 (diff)
Added by Dominic Cleal over 4 years ago

fixes #12194 - join fact tables multiple times for each search term

scoped_search usually generates a new inner join for each search term
when searching through a key/value table layout to correctly search for
hosts via multiple facts. Since the change to ext_method in 3f8e6c33, a
fixed table name was used. This is changed to multiple joins to match
how scoped_search works with multiple search terms.

Revision dcb7f5da (diff)
Added by Dominic Cleal over 4 years ago

fixes #12194 - join fact tables multiple times for each search term

scoped_search usually generates a new inner join for each search term
when searching through a key/value table layout to correctly search for
hosts via multiple facts. Since the change to ext_method in 3f8e6c33, a
fixed table name was used. This is changed to multiple joins to match
how scoped_search works with multiple search terms.

(cherry picked from commit 57e9d8a360625afb6dfe292655cc03cd65719073)

History

#2 Updated by Marek Hulán over 4 years ago

Despite the fact that it changed previous behaviour, isn't this actually expected?

#3 Updated by Timo Goebel over 4 years ago

Marek Hulán wrote:

Despite the fact that it changed previous behaviour, isn't this actually expected?

I can't follow. Why should this be expected behavior? Searching for hosts by two or more facts seems a reasonable requirement for me. For example I might want to search for hosts that have jruby and mysql installed. This is an arbitrary example, but - unfortunately - currently broken.

#4 Updated by Marek Hulán over 4 years ago

Ah sorry, I misunderstood what you try to search for, I thought you were trying to search facts, not hosts. Ok, sounds as a valid bug.

#5 Updated by Dominic Cleal over 4 years ago

  • Related to Feature #11150: Allow searching of facts as types other than string added

#6 Updated by Dominic Cleal over 4 years ago

  • Legacy Backlogs Release (now unused) set to 63

Daniel Lobato Garcia wrote:

https://github.com/theforeman/foreman/commit/3f8e6c33624f33acd65b371bf67549606397286e this looks like the culprit - investigating...

Yes, reverting this seems to fix it.

#7 Updated by Ohad Levy over 4 years ago

I believe this is happening when having a two joins on the same table, this was fixed in the past on scoped search at https://github.com/wvanbergen/scoped_search/commit/a7666e4b0a44cf1c066848cc8ab2f57301a7a218.

the solution should be to add aliases to table join, per condition set (name / value), however from a quick glance I'm not sure how to resolve it within the current implementation of external method.

AFAIR forcing a join should trigger the join aliasing code in scoped search.

#8 Updated by Ohad Levy over 4 years ago

I think the right way to solve it is probably via a patch to scoped_search, as there is no way to control the join statement from within the ext_method.

#9 Updated by Dominic Cleal over 4 years ago

  • Status changed from New to Assigned
  • Assignee set to Dominic Cleal

Ohad Levy wrote:

I think the right way to solve it is probably via a patch to scoped_search, as there is no way to control the join statement from within the ext_method.

I don't think that's correct, it appears that joins can be controlled by adding a joins element to the returned hash: https://github.com/wvanbergen/scoped_search/blob/v3.2.2/lib/scoped_search/query_builder.rb#L388-L394

#10 Updated by The Foreman Bot over 4 years ago

  • Status changed from Assigned to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/2906 added

#11 Updated by Dominic Cleal over 4 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100

Also available in: Atom PDF