I have a table 'client' with a unique index on column 'nome'
I have also set validates :uniqueness => true on column 'nome'
There is a record 'João Victor Santos' on my clients table. When I try
to insert another 'João Victor Santos' Rails executes the following
command to check if a record with this name already exists:
SELECT `clients`.`id` FROM `clients` WHERE (`clients`.`nome` = BINARY
'JoÃ£o Victor Santos') LIMIT 1
Unfortunately this query returns 0 rows and validation passes and I
receive this stack trace
Mysql::Error: Duplicate entry 'João Victor Santos' for key 2
If I execute this query in phpMyAdmin it correctly returns 1 result
SELECT `clients`.`id` FROM `clients` WHERE (`clients`.`nome` = 'João
Victor Santos') LIMIT 1
I'm using Rails 3.0.3, Ruby 1.8.7 and the mysql gem. I can't switch to
mysql2 gem because I'm running on Windows and this application will also
run on Windows in production
Has anyone faced this problem?