Project

General

Profile

Bug #9097

Typo in value_to_sql method causes ext_method searches with LIKE to not be applied

Added by David Davis over 4 years ago. Updated 11 months ago.

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

Description

Found a bug here:

https://github.com/theforeman/foreman/blob/ee1f56de6b2bdca4dfd104b99ec25340bfb51aaa/app/models/concerns/scoped_search_extensions.rb#L7

I believe that should be ~= instead of ~. The reason we're not seeing any bugs? Looks like it's being rescued here:

https://github.com/wvanbergen/scoped_search/blob/v2.7.1/lib/scoped_search/query_builder.rb#L371

To test, I think this should reproduce the problem:

1. Create a host
2. Try to filter by one of the affected search scopes (e.g. 'user_id = 999999'). Make sure you use '=' in your search.

Your host should still be visible when it ought not to be.

Associated revisions

Revision e86494a8 (diff)
Added by David Davis over 4 years ago

Fixes #9097 - Fix typo in value_to_sql method

Revision acab155d (diff)
Added by David Davis over 4 years ago

Fixes #9097 - Fix typo in value_to_sql method

(cherry picked from commit e86494a89e3b7f71850b6582be4d05b7badaab21)

History

#1 Updated by David Davis over 4 years ago

s/~=/=~/

#2 Updated by David Davis over 4 years ago

Actually, here are the fixed steps to reproduce:

1. Create a host
2. Try to filter by one of the affected search scopes (e.g. 'user.firstname = nonexitent_name'). Make sure you use '=' in your search.

#3 Updated by David Davis over 4 years ago

  • Status changed from New to Closed

Can't reproduce.

#4 Updated by David Davis over 4 years ago

  • Status changed from Closed to New

eLobato found the commit which shows it should be =~ as the code was moved:

https://github.com/theforeman/foreman/commit/e44f5c1c08d3f332b13fadd442dd754597db2b90

#5 Updated by David Davis over 4 years ago

Actually, in the steps to reproduce it should be "~" and not "=". Here are the steps:

1. Create a host
2. Go to the hosts page and search on "user.firstname ~ dfsjklfdsjlk" or some first name that doesn't exist.

Your host will be visible even though it shouldn't be.

#6 Updated by The Foreman Bot over 4 years ago

  • Status changed from New to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/2105 added
  • Pull request deleted ()

#7 Updated by David Davis over 4 years ago

  • Subject changed from Found a bug in the code to Typo in value_to_sql method causes ext_method searches with LIKE to not be applied

#8 Updated by Dominic Cleal over 4 years ago

  • Assignee set to David Davis

#9 Updated by David Davis over 4 years ago

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

#10 Updated by Dominic Cleal over 4 years ago

  • Legacy Backlogs Release (now unused) set to 30

Also available in: Atom PDF