Content
View differences
Updated by Eric Schubert over 1 year ago
### Steps to reproduce
1. Have a custom field of type hierarchy that is marked as "Searchable"
2. Provide a value for the custom field on a work package
### What is the buggy behavior?
* Search for the value in the project search
### What is the expected behavior?
1. Have the work package found if the search string matches the value selected for the work package
OR:
1. Remove the option from the custom field form
### Screenshots and other files
Work package can be filtered for by the value "Berlin"
### <img class="op-uc-image op-uc-image_inline" src="/api/v3/attachments/241533/content">
The same custom field cannot be found by inserting "Berlin" into the search
<img class="op-uc-image op-uc-image_inline" src="/api/v3/attachments/241534/content">
<img class="op-uc-image op-uc-image_inline" src="/api/v3/attachments/241535/content">
The CF is marked as searchable
<img class="op-uc-image op-uc-image_inline" src="/api/v3/attachments/241536/content">
### Information
* the custom values of custom fields of type list do have special handling in `act_as_searchable.rb`
```ruby
def build_custom_field_condition(custom_field_ids)
CustomValue.select("1")
.joins(<<~SQL.squish)
LEFT JOIN custom_options
ON custom_options.custom_field_id = custom_values.custom_field_id
AND custom_options.id::VARCHAR = custom_values.value
SQL
.where(customized_type: name, custom_field_id: custom_field_ids)
.where("customized_id=#{table_name}.id")
.where("(custom_values.value ILIKE ?) OR (custom_options.value ILIKE ?)")
end
```
* usually this kind of code should go into responsibility of the custom field itself
1. Have a custom field of type hierarchy that is marked as "Searchable"
2. Provide a value for the custom field on a work package
### What is the buggy behavior?
* Search for the value in the project search
### What is the expected behavior?
1. Have the work package found if the search string matches the value selected for the work package
OR:
1. Remove the option from the custom field form
### Screenshots and other files
Work package can be filtered for by the value "Berlin"
### <img class="op-uc-image op-uc-image_inline" src="/api/v3/attachments/241533/content">
The same custom field cannot be found by inserting "Berlin" into the search
<img class="op-uc-image op-uc-image_inline" src="/api/v3/attachments/241534/content">
The CF is marked as searchable
<img class="op-uc-image op-uc-image_inline" src="/api/v3/attachments/241536/content">
### Information
* the custom values of custom fields of type list do have special handling in `act_as_searchable.rb`
```ruby
def build_custom_field_condition(custom_field_ids)
CustomValue.select("1")
.joins(<<~SQL.squish)
LEFT JOIN custom_options
ON custom_options.custom_field_id = custom_values.custom_field_id
AND custom_options.id::VARCHAR = custom_values.value
SQL
.where(customized_type: name, custom_field_id: custom_field_ids)
.where("customized_id=#{table_name}.id")
.where("(custom_values.value ILIKE ?) OR (custom_options.value ILIKE ?)")
end
```
* usually this kind of code should go into responsibility of the custom field itself