lib/query_helper.rb in query_helper-0.3.6 vs lib/query_helper.rb in query_helper-0.3.8

- old
+ new

@@ -8,10 +8,11 @@ require "query_helper/sql_parser" require "query_helper/sql_manipulator" require "query_helper/sql_filter" require "query_helper/sql_sort" require "query_helper/invalid_query_error" +require "query_helper/invalid_sort_param_error" class QueryHelper attr_accessor :model, :bind_variables, :sql_filter, :sql_sort, :page, :per_page, :single_record, :associations, :as_json_options, :executed_query, :api_payload, :preload, :search_field, :search_string, :metadata attr_reader :query @@ -279,10 +280,10 @@ def search_filter(column_maps) raise ArgumentError.new("search_fields not defined") unless @search_fields.length > 0 placement = :where maps = column_maps.select do |cm| placement = :having if cm.aggregate - @search_fields.include? cm.alias_name + @search_fields.map(&:downcase).include? cm.alias_name.downcase end bind_variable = ('a'..'z').to_a.shuffle[0,20].join.to_sym @bind_variables[bind_variable] = "%#{@search_string}%" filter = "#{maps.map{|m| "coalesce(#{m.sql_expression}::varchar, '')"}.join(" || ")} ilike :#{bind_variable}" return {