I have the same question like here. But couldn't comment there because of not enough credits so creating new question.
Anyway the question is:
I want to compare two strings in ruby in the similar way how mysql compares two string with collation utf_general_ci.
To go in detail, when the collation utf_general_ci is selected in db, the mysql treat 'a' and 'ä' are same while executing queries. Since I want a batch inserts I am pulling all names (column with utf_general_ci collation) into ruby script and making insert statements if not name not exists. But during comparison in ruby the characters like 'a' and 'ä' are treated different. But I want the comparison to be implemented in a similar way how mysql does it in case of utf_general_ci collation.
In the old question there was an answer using 'iconv', which is deprecated after 1.9.3. So I think String#encode should be used in doing same. But couldn't find exact way how to replicate that behavior.
INSERT ... ON DUPLICATE KEY UPDATE ...avoids the need to check if a row exists before inserting it.SELECThas to spend the time to do the check. By combining the check and the insert/update, it actually saves time. Perhaps I can be clearer (or possibly wrong) if you can show the queries you have now.