[Dbix-class] inflate? select? turning on utf8 for mysql till the dbd is upgraded

apv apv at sedition.com
Fri Feb 10 04:13:32 CET 2006


So, this is great and I've got a quick take on the module for it but I
must be doing something wrong b/c it's not working. I also need to
learn how to use the DBIC::Test stuff to write proper tests for it.
I've never looked at the internals of DBIC either so I'll do that if I
get time in the next couple days, or someone could just straighten
me out. :)

"Module" attached.

-Ashley

-------------- next part --------------
A non-text attachment was scrubbed...
Name: DBIx-Class-UTF8Columns-0.01.tar.gz
Type: application/x-gzip
Size: 3057 bytes
Desc: not available
Url : http://lists.rawmode.org/pipermail/dbix-class/attachments/20060209/14c96d91/DBIx-Class-UTF8Columns-0.01.tar.bin
-------------- next part --------------


On Thursday, February 9, 2006, at 06:35  AM, Matt S Trout wrote:

> 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/ +
>
> _______________________________________________
> List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
> Wiki: http://dbix-class.shadowcatsystems.co.uk/
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
>
>


More information about the Dbix-class mailing list