MySQL is the only database I'm aware of for which `select 'Bla' = 'bla';`
returns true.  So while it looks odd from a MySQL user's perspective to
perform LOWER on both sides, it's the correct way to do case insensitive
matching on a SQL92 database.  Also, on databases like PostgreSQL and Oracle
at least, you can use functional indexes (e.g. `CREATE INDEX
users_lower_email_idx ON users (LOWER(email))`) to make these lookups fast.

For your case, you should probably just not use the `:case_insensitive`
flag, and know that MySQL is going to compare insensitively anyway.  Even
though aesthetically I'd like to see the Rails MySQL adapter behave
consistently with the other databases (be case sensitive by default), I
think it might be quite a rabbithole if Rails tried to force MySQL to do
string comparison case sensitively because of MySQL's lack of support for
functional indexes.  From a quick browse, there appears to be no way to
perform indexed string equality lookups on the same column both case
sensitively and insensitively -- you'd have to create a pair of columns, one
with case sensitive collation, the other without, in order to efficiently
look up the content both ways.  I'm not a MySQL expert though.

-john

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To post to this group, send email to rubyonrails-core@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-core+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en.

Reply via email to