app/models/query_builder.rb
def build_filter_logic (filter)
    column = filter[:column]
    values = filter[:values]
    op = filter[:op]

    column_type = Utils.column_type(@model_klass, column)

    values_expr = build_values_expr(values, column_type, op)
    return 0 unless values_expr

    column_expr = build_column_expr(column, column_type, op)
    return 0 unless column_expr

    op_expr = build_op_expr(op)
    return 0 unless op_expr

    "#{column_expr} #{op_expr} #{values_expr}"
  end
# Translates a filter into logic for augmenting the query.
#
# Can return any of the following:
# * a string suitable for a 'where' condition, to add to the query in play
# * the modified query object - this will REPLACE the current query in play
# * the modified filter object - this will REPLACE the current filter in play
# * nil, to "pass" but let the flow of filter application continue as normal
# * 0, if the filter is invalid (i.e. has no meaning), and therefore would
#   lead to no results. This stops filter application forthwith, and modifies
#   the entire query to return no results.
#
# @param filter [Hash] the filter, with a minimum format as follows:
#   { column: 'some-column-name', value: [val1, ...], op: 'some-op' }.
#   The filter is guaranteed to have at least one value
#
# @return [String, ActiveRecord::Relation, nil, false] See write-up above for
#   details
Translates a filter into logic for augmenting the query.
Can return any of the following:
a string suitable for a 'where' condition, to add to the query in play
the modified query object - this will REPLACE the current query in play
the modified filter object - this will REPLACE the current filter in play
nil, to "pass" but let the flow of filter application continue as normal
0, if the filter is invalid , and therefore would
lead to no results. This stops filter application forthwith, and modifies
the entire query to return no results.
Translates a filter into logic for augmenting the query . Can return any of the following : a string suitable for a ' where ' condition to add to the query in play the modified query object - this will REPLACE the current query in play the modified filter object - this will REPLACE the current filter in play nil to " pass " but let the flow of filter application continue as normal 0 if the filter is invalid and therefore would lead to no results . This stops filter application forthwith and modifies the entire query to return no results .
def build_filter_logic (filter)
    column = filter[:column]
    values = filter[:values]
    op = filter[:op]
    column_type = Utils.column_type(@model_klass, column)
    values_expr = build_values_expr(values, column_type, op)
    return 0 unless values_expr
    column_expr = build_column_expr(column, column_type, op)
    return 0 unless column_expr
    op_expr = build_op_expr(op)
    return 0 unless op_expr
    "#{column_expr} #{op_expr} #{values_expr}"
  end
def build_filter_logic ( filter ) column = filter [ :column ] values = filter [ :values ] op = filter [ :op ] column_type = Utils . column_type ( @model_klass , column ) values_expr = build_values_expr ( values , column_type , op ) return 0 unless values_expr column_expr = build_column_expr ( column , column_type , op ) return 0 unless column_expr op_expr = build_op_expr ( op ) return 0 unless op_expr "#{column_expr} #{op_expr} #{values_expr}" end
Translates a filter into logic for augmenting the query.
Translates a filter into logic for augmenting the query .
See write-up above for details
See write - up above for details
String, ActiveRecord::Relation, nil, false
filter
the filter, with a minimum format as follows: { column: 'some-column-name', value: [val1, ...], op: 'some-op' }. The filter is guaranteed to have at least one value
the filter with a minimum format as follows : { column : ' some - column - name ' value : [ val1 ... ] op : ' some - op ' } . The filter is guaranteed to have at least one value