Skip to content

Commit

Permalink
use LIKE instead of LOWER to take advantage of database indices
Browse files Browse the repository at this point in the history
  • Loading branch information
binarylogic committed May 1, 2011
1 parent a8835ab commit ca37d8a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/authlogic/acts_as_authentic/login.rb
Expand Up @@ -118,7 +118,8 @@ def find_with_case(field, value, sensitivity = true)
if sensitivity
send("find_by_#{field}", value)
else
where("LOWER(#{quoted_table_name}.#{field}) = ?", value.mb_chars.downcase).first
like_word = ::ActiveRecord::Base.connection.adapter_name == "PostgreSQL" ? "ILIKE" : "LIKE"
where("#{quoted_table_name}.#{field} #{like_word} ?", value.mb_chars).first
end
end
end
Expand Down

0 comments on commit ca37d8a

Please sign in to comment.