[Dbix-class] inflate? select? turning on utf8 for mysql till the
dbd is upgraded
Matt S Trout
dbix-class at trout.me.uk
Thu Feb 9 15:35:39 CET 2006
On Wed, Feb 08, 2006 at 10:50:07PM -0800, apv wrote:
> In CDBI for MySQL I'm setting everything to utf8 this way (the tables
> are utf8 but the DBD doesn't bring the info across):
>
> # the base class
> use Data::Structure::Util qw( _utf8_on );
> __PACKAGE__->add_trigger(select => sub { _utf8_on($_[0]) });
>
> How would I go about turning on the utf-8 flag for everything via DBIC?
Something like
package DBIx::Class::UTF8Columns;
sub inflate_result {
my $self = shift;
my $columns = $_[0];
foreach my $key (keys %$columns) {
_utf8_on($columns->{$key}) if $self->column_info($key)->{utf8};
return $self->next::method(@_);
}
sub store_column {
my $self = shift;
_utf8_on($_[1]) if $self->column_info($_[0])->{utf8};
return $self->next::method(@_);
}
then do
->load_components('UTF8Columns');
->add_columns(foo => { utf8 => 1 }, ...);
If you can clean it up and add tests I'd love to see this added to the
-current branch.
> PS: sorry for the double mail, Matt
No worries :)
--
Matt S Trout Offering custom development, consultancy and support
Technical Director contracts for Catalyst, DBIx::Class and BAST. Contact
Shadowcat Systems Ltd. mst (at) shadowcatsystems.co.uk for more information
+ Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +
More information about the Dbix-class
mailing list