@@ -56,7 +56,7 @@ def search_param
56
56
conditions = [ ]
57
57
58
58
@resource . columns . each_with_index do |column , index |
59
- @fields_searched << column . name if [ :string , :text ] . include ? column . type
59
+ @fields_searched << column . name if text_type ? column . type
60
60
column_name = format_column_name ( @resource . table_name , column . name )
61
61
if ( @collection . search_fields && !@collection . search_fields . include? ( column . name ) )
62
62
conditions
@@ -73,8 +73,7 @@ def search_param
73
73
!@resource . defined_enums [ column . name ] [ @search . downcase ] . nil?
74
74
conditions << "#{ column_name } =
75
75
#{ @resource . defined_enums [ column . name ] [ @search . downcase ] } "
76
- elsif !( column . respond_to? ( :array ) && column . array ) &&
77
- ( column . type == :string || column . type == :text )
76
+ elsif !( column . respond_to? ( :array ) && column . array ) && text_type? ( column . type )
78
77
conditions << "LOWER(#{ column_name } ) LIKE :search_value_for_string"
79
78
end
80
79
end
@@ -101,8 +100,7 @@ def search_param
101
100
if @includes . include? association . to_sym
102
101
resource = @resource . reflect_on_association ( association . to_sym )
103
102
resource . klass . columns . each do |column |
104
- if !( column . respond_to? ( :array ) && column . array ) &&
105
- ( column . type == :string || column . type == :text )
103
+ if !( column . respond_to? ( :array ) && column . array ) && text_type? ( column . type )
106
104
if @collection . search_fields . nil? || ( association_search &&
107
105
association_search . include? ( column . name ) )
108
106
conditions << association_search_condition ( resource . table_name ,
@@ -125,8 +123,7 @@ def search_param
125
123
unless association_search . empty?
126
124
resource = @resource . reflect_on_association ( association . to_sym )
127
125
resource . klass . columns . each do |column |
128
- if !( column . respond_to? ( :array ) && column . array ) &&
129
- ( column . type == :string || column . type == :text )
126
+ if !( column . respond_to? ( :array ) && column . array ) && text_type? ( column . type )
130
127
if association_search . include? ( column . name )
131
128
conditions << association_search_condition ( resource . table_name ,
132
129
column . name )
@@ -278,5 +275,11 @@ def belongs_to_filter
278
275
279
276
@records
280
277
end
278
+
279
+ private
280
+
281
+ def text_type? ( type_sym )
282
+ [ :string , :text , :citext ] . include? type_sym
283
+ end
281
284
end
282
285
end
0 commit comments