Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Rollback to LOWER comparison instead of (I)LIKE because of bug and in…

…ability to use index with ILIKE for Postgres
  • Loading branch information...
commit a889f9a3f3611ece7a764edc02fb86e83e32d208 1 parent 7aed570
@cris authored
Showing with 2 additions and 3 deletions.
  1. +2 −3 lib/authlogic/acts_as_authentic/login.rb
View
5 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
Please sign in to comment.
Something went wrong with that request. Please try again.