Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollback to LOWER comparison instead of (I)LIKE because of bug and poor Postgres performance #339

Merged
merged 1 commit into from Dec 7, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 2 additions & 3 deletions lib/authlogic/acts_as_authentic/login.rb
Expand Up @@ -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 # 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: # 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: # If you don't specify this it calls the good old find_by_* method:
# #
Expand All @@ -118,8 +118,7 @@ def find_with_case(field, value, sensitivity = true)
if sensitivity if sensitivity
send("find_by_#{field}", value) send("find_by_#{field}", value)
else else
like_word = ::ActiveRecord::Base.connection.adapter_name == "PostgreSQL" ? "ILIKE" : "LIKE" where("LOWER(#{quoted_table_name}.#{field}) = ?", value.mb_chars.downcase).first
where("#{quoted_table_name}.#{field} #{like_word} ?", value.mb_chars).first
end end
end end
end end
Expand Down