[LRUG] MySQL/Rails Collation

Riccardo Tacconi rtacconi at gmail.com
Mon Jan 23 09:05:06 PST 2012


I had a similar error. You have to change tables and columns to UTF-8.
There should be a script but you can do it manually. Yes Rails should look
after to those details, I guess it could be a bug (it happened to me with
Rails 2.3.12). You could put the SQL command to fix the issue in a
migration...

On 23 January 2012 17:56, Andrew Stewart <boss at airbladesoftware.com> wrote:

> Hola El Rug,
>
> I have a Rails app which started life as Rails 2.x and is now Rails 3.0.y.
>  It sits on top of a MySQL database.
>
> I have just started to see collation errors both at the Rails level and in
> the mysql console.  For example:
>
>    mysql> select * from samples where code = 'abcd‐01‐s10‐036';
>    ERROR 1267 (HY000): Illegal mix of collations
> (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation
> '='
>
>    mysql> show create table samples;
>    [snip] ENGINE=InnoDB AUTO_INCREMENT=54307 DEFAULT CHARSET=latin1
>
> In the Rails console:
>
>    >> ActiveRecord::Base.connection.collation
>    "latin1_swedish_ci"
>
> Now I thought Rails ensured everything from top to toe was UTF-8;
> apparently not in this case.  Anyway, how do I best fix this (while staying
> with MySQL)?
>
> Thanks in advance.
>
> Yours,
> Andy Stewart
>
> -------
> http://airbladesoftware.com
> _______________________________________________
> Chat mailing list
> Chat at lists.lrug.org
> http://lists.lrug.org/listinfo.cgi/chat-lrug.org
>



-- 
Riccardo Tacconi
Ruby on Rails and PHP development - System Administration
VIRTUELOGIC LIMITED

http://github.com/rtacconi
http://riccardotacconi.blogspot.com
http://twitter.com/rtacconi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lrug.org/pipermail/chat-lrug.org/attachments/20120123/8fb38790/attachment-0003.html>


More information about the Chat mailing list