Skip to content

Commit f997659

Browse files
fix(search): fix search on fields of type UUID (#560)
1 parent eb4fedf commit f997659

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

app/services/forest_liana/search_query_builder.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def search_param
6161
conditions = []
6262

6363
@resource.columns.each_with_index do |column, index|
64-
@fields_searched << column.name if text_type? column.type
64+
@fields_searched << column.name if text_type?(column.type) || column.type == :uuid
6565
column_name = format_column_name(@resource.table_name, column.name)
6666
if (@collection.search_fields && !@collection.search_fields.include?(column.name))
6767
conditions
@@ -73,6 +73,8 @@ def search_param
7373
conditions << "#{@resource.table_name}.id = :search_value_for_uuid"
7474
end
7575
# NOTICE: Rails 3 do not have a defined_enums method
76+
elsif REGEX_UUID.match(@search) && column.type == :uuid
77+
conditions << "#{column_name} = :search_value_for_uuid"
7678
elsif @resource.respond_to?(:defined_enums) &&
7779
@resource.defined_enums.has_key?(column.name) &&
7880
!@resource.defined_enums[column.name][@search.downcase].nil?

0 commit comments

Comments
 (0)