Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change validates_uniqueness_of :case_sensitive option default back to…
… true (from [9160]). Love your database columns, don't LOWER them. [rick] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9248 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
- Loading branch information
1 parent
c67e985
commit ed99dda
Showing
2 changed files
with
4 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
ed99dda
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There’s an issue which has cropped up in this method, which is that there’s no need to LOWER, and yet MySQL is penalized in the case insensitive mode with unnecessary and utter destruction of its index utilitization. It wasn’t an issue before 2.1 because validates_uniqueness_of was effectively insensitive by default on MySQL (oops).
ed99dda
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I second kemiller’s comment. It’s a big issue on large tables with millions or rows getting scanned.
ed99dda
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a temporary fix, I overrode validations.rb at line 627 with:
```
if value.nil? || (configuration[:case_sensitive] || !is_text_column) || self.connection.class.is_a?(ActiveRecord::ConnectionAdapters::MysqlAdapter)
….
```
ed99dda
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops, what I just wrote was wrong, I meant:
if value.nil? || (configuration[:case_sensitive] || !is_text_column) || self.connection.is_a?(ActiveRecord::ConnectionAdapters::MysqlAdapter)
ed99dda
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please open a thread on the core mailing list http://groups.google.com/group/rubyonrails-core rather than discussing this here, otherwise it’s likely to get forgotten and not be fixed in the next point release.