File tree Expand file tree Collapse file tree 4 files changed +12
-14
lines changed Expand file tree Collapse file tree 4 files changed +12
-14
lines changed Original file line number Diff line number Diff line change @@ -282,12 +282,8 @@ def search_filter(column_maps)
282
282
raise ArgumentError . new ( "search_fields not defined" ) unless @search_fields . length > 0
283
283
placement = :where
284
284
maps = column_maps . select do |cm |
285
- if @search_fields . include? cm . alias_name
286
285
placement = :having if cm . aggregate
287
- true
288
- else
289
- false
290
- end
286
+ @search_fields . include? cm . alias_name
291
287
end
292
288
bind_variable = ( 'a' ..'z' ) . to_a . shuffle [ 0 , 20 ] . join . to_sym
293
289
@bind_variables [ bind_variable ] = "%#{ @search_string } %"
Original file line number Diff line number Diff line change @@ -21,13 +21,15 @@ def create_filters
21
21
raise InvalidQueryError . new ( "cannot filter by #{ comparate_alias } " ) unless map
22
22
23
23
# create the filter
24
- @filters << QueryHelper ::Filter . new (
25
- operator_code : criteria . keys . first ,
26
- criterion : criteria . values . first ,
27
- comparate : map . sql_expression ,
28
- aggregate : map . aggregate ,
29
- qualify_clause : aggregated_attribute? ( comparate : map . sql_expression )
30
- )
24
+ criteria . each do |k , v |
25
+ @filters << QueryHelper ::Filter . new (
26
+ operator_code : k ,
27
+ criterion : v ,
28
+ comparate : map . sql_expression ,
29
+ aggregate : map . aggregate ,
30
+ qualify_clause : aggregated_attribute? ( comparate : map . sql_expression )
31
+ )
32
+ end
31
33
end
32
34
end
33
35
Original file line number Diff line number Diff line change @@ -188,7 +188,7 @@ def find_aliases
188
188
ColumnMap . new (
189
189
alias_name : sql_alias ,
190
190
sql_expression : sql_expression . squish ,
191
- aggregate : /\b (array_agg|avg|bit_and|bit_or|bool_and|bool_or|boolor_agg|booland_agg|count|every|json_agg|jsonb_agg|json_object_agg|jsonb_object_agg|max|min|string_agg|sum|xmlagg)\( (.*)\) / . match? ( sql_expression )
191
+ aggregate : /(?i) \b (array_agg|avg|bit_and|bit_or|bool_and|bool_or|boolor_agg|booland_agg|count|every|json_agg|jsonb_agg|json_object_agg|jsonb_object_agg|max|min|string_agg|sum|xmlagg|any_value )\( (.*)\) / . match? ( sql_expression )
192
192
) if sql_alias
193
193
end
194
194
column_maps . compact
Original file line number Diff line number Diff line change 1
1
class QueryHelper
2
- VERSION = "0.4.2 "
2
+ VERSION = "0.4.3 "
3
3
end
You can’t perform that action at this time.
0 commit comments