Permalink
Browse files

Merge pull request #339 from cris/back-to-lower

Rollback to LOWER comparison instead of (I)LIKE because of bug and poor Postgres performance
  • Loading branch information...
2 parents 7aed570 + a889f9a commit d8c61db3d6179de46019fdfb074379e2711a3b96 @binarylogic committed Dec 7, 2012
Showing with 2 additions and 3 deletions.
  1. +2 −3 lib/authlogic/acts_as_authentic/login.rb
@@ -94,7 +94,7 @@ def merge_validates_uniqueness_of_login_field_options(options = {})
# manner that they handle that. If you are using the login field and set false for the :case_sensitive option in
# validates_uniqueness_of_login_field_options this method will modify the query to look something like:
#
- # where("#{quoted_table_name}.#{field} LIKE ?", login).first
+ # where("LOWER(#{quoted_table_name}.#{login_field}) = ?", login.downcase).first
#
# If you don't specify this it calls the good old find_by_* method:
#
@@ -118,8 +118,7 @@ def find_with_case(field, value, sensitivity = true)
if sensitivity
send("find_by_#{field}", value)
else
- like_word = ::ActiveRecord::Base.connection.adapter_name == "PostgreSQL" ? "ILIKE" : "LIKE"
- where("#{quoted_table_name}.#{field} #{like_word} ?", value.mb_chars).first
+ where("LOWER(#{quoted_table_name}.#{field}) = ?", value.mb_chars.downcase).first
end
end
end

0 comments on commit d8c61db

Please sign in to comment.