@@ -96,7 +96,8 @@ def parse_condition_without_smart_field(condition)
9696 value = current_resource . defined_enums [ association_field ] [ value ]
9797 end
9898
99- parsed_field = parse_field_name ( field_name )
99+ case_insensitive = operator == 'i_contains'
100+ parsed_field = parse_field_name ( field_name , case_insensitive )
100101 parsed_operator = parse_operator ( operator )
101102 parsed_value = parse_value ( operator , value )
102103 field_and_operator = "#{ parsed_field } #{ parsed_operator } "
@@ -120,7 +121,7 @@ def parse_operator(operator)
120121 '>'
121122 when 'less_than' , 'before'
122123 '<'
123- when 'contains' , 'starts_with' , 'ends_with'
124+ when 'contains' , 'starts_with' , 'ends_with' , 'i_contains'
124125 'LIKE'
125126 when 'not_contains'
126127 'NOT LIKE'
@@ -145,6 +146,8 @@ def parse_value(operator, value)
145146 value
146147 when 'contains' , 'not_contains'
147148 "%#{ value } %"
149+ when 'i_contains'
150+ "%#{ value . downcase } %"
148151 when 'starts_with'
149152 "#{ value } %"
150153 when 'ends_with'
@@ -161,7 +164,7 @@ def parse_value(operator, value)
161164 end
162165 end
163166
164- def parse_field_name ( field )
167+ def parse_field_name ( field , insensitive = false )
165168 if is_belongs_to ( field )
166169 current_resource = @resource . reflect_on_association ( field . split ( ':' ) . first . to_sym ) &.klass
167170 raise ForestLiana ::Errors ::HTTP422Error . new ( "Field '#{ field } ' not found" ) unless current_resource
@@ -181,7 +184,7 @@ def parse_field_name(field)
181184 raise ForestLiana ::Errors ::HTTP422Error . new ( "Field '#{ field } ' not found" )
182185 end
183186
184- "#{ quoted_table_name } .#{ quoted_field_name } "
187+ insensitive ? "LOWER( #{ quoted_table_name } . #{ quoted_field_name } )" : "#{ quoted_table_name } .#{ quoted_field_name } "
185188 end
186189
187190 def is_belongs_to ( field )
0 commit comments