Reputation: 14967
I'm using Mysql with collation utf8_general_ci
and for most of my searches it is good. But for one model and one field I want to find a record with case sensitive. How to do it?
Upvotes: 2
Views: 2500
Reputation: 34271
It is MySQL that is doing the case insensitive query, not Ruby on Rails.
See http://dev.mysql.com/doc/refman/5.0/en/case-sensitivity.html
You could make database columns, that require case sensitivity to be case sensitive
-
create table tbl_name (
...
data varchar COLLATE latin1_bin
)
Or you can modify your queries to use COLLATE operator:
SELECT * from tbl_name WHERE col_name COLLATE latin1_bin LIKE 'a%'
Upvotes: 3
Reputation: 31961
If you always want to search that column in a case sensitive manner, the best thing would be to define it with collation utf8_bin
Upvotes: 0