rails, mysql charsets & encoding: binary
Posted
by Benjamin Vetter
on Stack Overflow
See other posts from Stack Overflow
or by Benjamin Vetter
Published on 2010-05-21T13:21:31Z
Indexed on
2010/05/21
13:30 UTC
Read the original article
Hit count: 447
Hi,
i've a rails app that runs using utf-8. It uses a mysql database, all tables with mysql's default charset and collation (i.e. latin1). Therefore the latin1 tables contain utf-8 data. Sure, that's not nice, but i'm not really interested in it. Everything works fine, because the connection encoding is latin1 as well and therefore mysql does not convert between charsets.
Only one problem: i need a utf-8 fulltext index for one table:
mysql> show create table autocompletephrases;
... AUTO_INCREMENT=310095 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
But: I don't want to convert between charsets in my rails app. Therefore I would like to know if i could just set config/database.yml
production:
adapter: mysql
>>>> encoding: binary
...
which just calls SET NAMES 'binary' when connecting to mySQL. It looks like it works for my case, because i guess it forces mysql to -not- convert between charsets (mySQL docs). Does anyone knows about problems about doing this? Any side-effects?
Or do you have any other suggestions? But i'd like to avoid converting my whole database to utf-8.
Many Thanks! Benjamin
© Stack Overflow or respective owner