Skip to content

Commit

Permalink
[#619 state:resolved] support case insensitive search on postgresql.
Browse files Browse the repository at this point in the history
thanks tomP
  • Loading branch information
bryanlarsen committed Feb 19, 2010
1 parent 2c3036c commit df9df4b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion hobo/lib/hobo.rb
Expand Up @@ -57,8 +57,9 @@ def find_by_search(query, search_targets=nil)
search_targets.build_hash do |search_target|
conditions = []
parameters = []
like_operator = ActiveRecord::Base.connection.adapter_name =~ /postgres/i ? 'ILIKE' : 'LIKE'
query_words.each do |word|
column_queries = search_target.search_columns.map { |column| "#{column} like ?" }
column_queries = search_target.search_columns.map { |column| "#{column} #{like_operator} ?" }
conditions << "(" + column_queries.join(" or ") + ")"
parameters.concat(["%#{word}%"] * column_queries.length)
end
Expand Down

0 comments on commit df9df4b

Please sign in to comment.