cloudfoundry-community-attic / cf-services-release

Cloud Foundry services release (includes mysql V1 service and gateway only)
Apache License 2.0
9 stars 25 forks source link

Set collation_connection on connection init #17

Closed rkoster closed 11 years ago

rkoster commented 11 years ago

When I provisioned a mysql database on the mysql_node to use with my rails application I run into the following error: ActiveRecord::StatementInvalid (Mysql2::Error: Illegal mix of collations (utf8_general_ci,IMPLICIT) and (utf8_unicode_ci,IMPLICIT) for operation '=': I found out that the collation_connection was set to utf8_general_ci. I was not able to change this connection at the rails side because I'm using the cf-autoconfig gem. And as a result the database.yml file is ignored.

RobDay-Reynolds commented 11 years ago

Should not collation_connection be set on a client side? Supposedly you created a database or a table with different collocation you can change it if you need it. Otherwise we are forcing clients to always connect with utf8_unicode_ci.

@monkeyherder & @mariash

rkoster commented 11 years ago

It could be set at the client side, I was however unable to do it in the database.yml file of our rails application because this file gets overwritten during staging.

RobDay-Reynolds commented 11 years ago

It looks like changing it in database.yml won't help anyway. You may want to try to set it like this:

ActiveRecord::Base.connection.execute "SET collation_database = 'utf8_general_ci' "
ActiveRecord::Base.connection.execute "SET collation_connection = 'utf8_general_ci' "

(from: https://www.ruby-forum.com/topic/164696)

mariash commented 11 years ago

This change will break things for users who choose to have a non-UTF-8 collation as it forces all clients to use utf8_general_ci collation.

As noted modifying database.yml will not work but @monkeyherder's suggestion should be a viable workaround for ActiveRecord.

Based on this we are closing this pull request.