@@ -75,7 +75,7 @@ module Search
75
75
76
76
scoped_search :relation => :fact_values , :on => :value , :in_key => :fact_names , :on_key => :name , :rename => :facts , :complete_value => true , :only_explicit => true , :ext_method => :search_cast_facts
77
77
scoped_search :relation => :search_parameters , :on => :name , :complete_value => true , :rename => :params_name , :only_explicit => true
78
- scoped_search :relation => :search_parameters , :on => :searchable_value , :in_key => :search_parameters , :on_key => :name , :complete_value => true , :rename => :params , :ext_method => :search_by_params , :only_explicit => true , :operators => [ '= ' , '~ ' ]
78
+ scoped_search :relation => :search_parameters , :on => :searchable_value , :in_key => :search_parameters , :on_key => :name , :complete_value => { true : 't' , false : 'f' } , :rename => :params , :ext_method => :search_by_params , :only_explicit => true , :operators => [ '= ' , '~ ' ]
79
79
80
80
scoped_search :relation => :reported_data , :on => :boot_time , :rename => 'boot_time' , :only_explicit => true
81
81
scoped_search :relation => :reported_data , :on => :boot_time , :rename => 'reported.boot_time' , :only_explicit => true
@@ -170,13 +170,15 @@ def search_by_hostgroup_and_descendants(key, operator, value)
170
170
end
171
171
172
172
def search_by_params ( key , operator , value )
173
+ # boolean value is saved as 't'/'f' in searchable_value column
174
+ normalized_value = value == 'true' ? 't' : 'f'
173
175
key_name = key . sub ( /^.*\. / , '' )
174
- condition = sanitize_sql_for_conditions ( [ "name = ? and searchable_value #{ operator } ?" , key_name , value_to_sql ( operator , value ) ] )
176
+ condition = sanitize_sql_for_conditions ( [ "name = ? and searchable_value #{ operator } ?" , key_name , value_to_sql ( operator , normalized_value ) ] )
175
177
p = Parameter . where ( condition ) . reorder ( :priority )
176
178
return { :conditions => '1 = 0' } if p . blank?
177
179
178
180
max = p . first . priority
179
- condition = sanitize_sql_for_conditions ( [ "name = ? and NOT(searchable_value #{ operator } ?) and priority > ?" , key_name , value_to_sql ( operator , value ) , max ] )
181
+ condition = sanitize_sql_for_conditions ( [ "name = ? and NOT(searchable_value #{ operator } ?) and priority > ?" , key_name , value_to_sql ( operator , normalized_value ) , max ] )
180
182
n = Parameter . where ( condition ) . reorder ( :priority )
181
183
182
184
conditions = param_conditions ( p )
0 commit comments