Rollback to LOWER comparison instead of (I)LIKE because of bug and poor Postgres performance#339
Merged
Merged
Conversation
…ability to use index with ILIKE for Postgres
|
+1. The ILIKE quoting issue is fairly serious, and switching back to LOWER seems like a good way to both fix it and improve performance on Postgres at the same time. It looks like the original switch to LIKE was done for "performance" reasons on MySQL, but wasn't thought through completely as it actually degraded performance on all versions of Postgres. (for reference here's the original LIKE commit) |
|
+1 this is a much better solution. |
binarylogic
added a commit
that referenced
this pull request
Dec 7, 2012
Rollback to LOWER comparison instead of (I)LIKE because of bug and poor Postgres performance
|
FWIW this change destroys performance on MySQL, since the use of |
pixeltrix
added a commit
to alphagov/e-petitions
that referenced
this pull request
Apr 28, 2015
As of Rails 4.2 enforcing case-sensitivity for usernames is broken in Authlogic due to the commit rails/rails@a38e957. The app change was for security reasons since at the time Authlogic was using LIKE in the query generation. However this was fixed in binarylogic/authlogic#339. - binarylogic/authlogic#444 - binarylogic/authlogic#453 We should leave it as case-insensitive as this is better UX
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi, Ben.
I suggest to revert changes with LIKE back to LOWER, because this solution doesn't add any benefits and introduce subtle bug.
allways returns user1 record. Take a look on issue 321, they already obtain this email collision: binarylogic/authlogic/issues/#321
For MySQL case-insensitive is usualy default, because Rails creates database with collation "utf8_general_ci", and with such collation search by string fields is case insensitive. So, MySQL doesn't benefit from LIKE, because it doesn't make sense for it to use such option. Plane find_by_#{field} does all in case-insensitive manner.
For Postgres ILIKE only brings new issue instead of solving something.
First of all, ILIKE can't use indexes. You can clearly see this via EXPLAIN:
What is worse, now I can't use Postgres ability to create index on function. For previous version of Authlogic I've created index on expression: LOWER(email) and it provides me with required functionality.
After update to the latest version of AuthLogic I lost such ability.
Please, apply this pull-request to handle all caveats.