Permalink
Browse files

* normalizing case in search.

  • Loading branch information...
1 parent 8b434d3 commit 4fb69519ff50214aee82acd34a918e3b22e714da Erik Hollensbe committed Aug 15, 2010
Showing with 3 additions and 3 deletions.
  1. +3 −3 lib/db/search.rb
View
@@ -10,10 +10,10 @@ def search_project_by_name_and_tech(name, techs)
on t.id = pt.tech_id
inner join projects p
on p.id = pt.project_id
- where p.name LIKE ?
+ where lower(p.name) LIKE ?
and lower(t.tech) in (] +
('?,' * techs.length).sub(/,$/, '') +
- ")", "%#{name}%", *techs.map(&:downcase)
+ ")", "%#{name.downcase}%", *techs.map(&:downcase)
).fetch(:all, :Struct).
collect do |project|
user = user_by_id(project.user_id)
@@ -26,7 +26,7 @@ def search_project_by_name_and_tech(name, techs)
def search_project_by_name(name)
name.gsub!(/%/, '')
return [] if name.empty?
- @dbh.execute("select * from projects where name LIKE ?", "%#{name}%").
+ @dbh.execute("select * from projects where lower(name) LIKE ?", "%#{name.downcase}%").
fetch(:all, :Struct).
collect do |project|
user = user_by_id(project.user_id)

0 comments on commit 4fb6951

Please sign in to comment.