[Dbix-class] Where to "encourage" UTF8...

Paul Makepeace paulm at paulm.com
Wed Dec 10 00:03:53 GMT 2008


For reasons I'm not clear on our MySQL / DBIC / Catalyst set-up has
lately started dropping utf8-ness. I had a dig around and there seem
to be a few solutions.

Matt's talk http://www.shadowcat.co.uk/catalyst/-talks/oscon/crucible.xul
suggests, slide 92 (which sadly I can't copy/paste) using an
on_connect_do. It doesn't say where exactly this goes but I'm assuming
in the schema base class? It didn't help in any case :-)

I read in http://dev.mysql.com/doc/refman/5.0/en/charset-general.html
a way of setting character set results, so tried this,

__PACKAGE__->config(
  schema_class => 'IDL::Schema',
  connect_info => [@IDL::Schema::connect_info],
  on_connect_do => [
    #'set names utf8',
    'SET character_set_results="utf8"',
  ],
);

That didn't appear to do anything either.

What /did/ work was, __PACKAGE__->load_components(qw/UTF8Columns/);
and then individually setting uft8_columns(qw/name etc/);

Any ideas why the first two didn't work? I'm not really excited about
setting UTF8 on every text column...

**

Stabbing at it from the database side, the db is latin1,

mysql> show variables like "character_set_database";
+------------------------+--------+
| Variable_name          | Value  |
+------------------------+--------+
| character_set_database | latin1 |
+------------------------+--------+

Attempting alter database default character set 'utf8'; alter database
character set 'utf8'; seems too easy and doesn't appear to help
either.

Maybe it needs to be reloading from scratch as utf8 or something?

P



More information about the DBIx-Class mailing list