开发者

rails, mysql charsets & encoding: binary

开发者 https://www.devze.com 2022-12-30 23:00 出处:网络
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 n

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. Ever开发者_C百科ything 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


I feel like there's compelling reason to just convert rather then introduce something that's going to temporarily solve your problem till you will end up needing to convert in the future.

i'd save yourself the future pain by just converting now.

0

精彩评论

暂无评论...
验证码 换一张
取 消