we really need to make our db case insensitive
This commit is contained in:
parent
7d4d08c59f
commit
16b892ccec
1 changed files with 5 additions and 0 deletions
|
|
@ -41,6 +41,9 @@ class Person < ActiveRecord::Base
|
|||
return [] if query.to_s.blank? || query.to_s.length < 3
|
||||
|
||||
where_clause = <<-SQL
|
||||
profiles.first_name LIKE ? OR
|
||||
profiles.last_name LIKE ? OR
|
||||
people.diaspora_handle LIKE ? OR
|
||||
profiles.first_name LIKE ? OR
|
||||
profiles.last_name LIKE ? OR
|
||||
people.diaspora_handle LIKE ?
|
||||
|
|
@ -51,9 +54,11 @@ class Person < ActiveRecord::Base
|
|||
query_tokens = query.to_s.strip.split(" ")
|
||||
query_tokens.each_with_index do |raw_token, i|
|
||||
token = "%#{raw_token}%"
|
||||
up_token = "%#{raw_token.titleize}%"
|
||||
sql << " OR " unless i == 0
|
||||
sql << where_clause
|
||||
tokens.concat([token, token, token])
|
||||
tokens.concat([up_token, up_token, up_token])
|
||||
end
|
||||
#SELECT `people`.* FROM people
|
||||
# INNER JOIN `profiles` ON `profiles`.person_id = `people`.id
|
||||
|
|
|
|||
Loading…
Reference in a new issue