[Dbix-class] I found a bug under UTF8Column

Matt S Trout dbix-class at trout.me.uk
Sat Mar 8 16:01:26 GMT 2008


You can't fix UTF8Columns by patching Row. Please try and supply a patch
that fixes the problem at source rather than polluting the rest of the code
base.

UTF8Columns is only really required (AFAIK) by sites stuck with old
DBD::mysql installs without proper utf8 support, so I don't want the
magic spilling out of it ...

On Fri, Mar 07, 2008 at 11:16:41PM +0900, Tomohiro Hosaka wrote:
> mbp bokutin % LANG=C svn info
> Path: .
> URL: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/0.08/trunk
> Repository Root: http://dev.catalyst.perl.org/repos/bast
> Repository UUID: bd8105ee-0ff8-0310-8827-fb3f25b6796d
> Revision: 4143
> Node Kind: directory
> Schedule: normal
> Last Changed Author: castaway
> Last Changed Rev: 4143
> Last Changed Date: 2008-03-07 08:26:08 +0900 (Fri, 07 Mar 2008)
> 
> mbp bokutin % LANG=C svn diff
> Index: t/85utf8.t
> ===================================================================
> --- t/85utf8.t	(revision 4143)
> +++ t/85utf8.t	(working copy)
> @@ -16,14 +16,14 @@
> eval 'use utf8; 1' or plan skip_all => 'Need utf8 run this test';
> }
> 
> -plan tests => 3;
> +plan tests => 5;
> 
> DBICTest::Schema::CD->load_components('UTF8Columns');
> DBICTest::Schema::CD->utf8_columns('title');
> Class::C3->reinitialize();
> 
> my $cd = $schema->resultset('CD')->create( { artist => 1, title =>  
> 'øni', year => 'foo' } );
> -my $utf8_char = 'uniuni';
> +my $utf8_char = 'øni';
> 
> if ($] <= 5.008000) {
> 
> @@ -31,6 +31,7 @@
> ok( !Encode::is_utf8( $cd->year ), 'got year without utf8 flag' );
> 
> Encode::_utf8_on($utf8_char);
> +    ok( Encode::is_utf8($utf8_char), "got utf8_char");
> $cd->title($utf8_char);
> ok( !Encode::is_utf8( $cd->{_column_data}{title} ), 'store utf8-less  
> chars' );
> 
> @@ -40,6 +41,10 @@
> ok( !utf8::is_utf8( $cd->year ), 'got year without utf8 flag' );
> 
> utf8::decode($utf8_char);
> +    ok( utf8::is_utf8($utf8_char), "got utf8_char");
> $cd->title($utf8_char);
> ok( !utf8::is_utf8( $cd->{_column_data}{title} ), 'store utf8-less  
> chars' );
> +
> }
> +
> +ok( !$cd->is_column_changed('title'), 'is_column_changed under  
> utf8columns' );
> Index: lib/DBIx/Class/Row.pm
> ===================================================================
> --- lib/DBIx/Class/Row.pm	(revision 4143)
> +++ lib/DBIx/Class/Row.pm	(working copy)
> @@ -469,6 +469,7 @@
> $self->{_orig_ident} ||= $self->ident_condition;
> my $old = $self->get_column($column);
> my $ret = $self->store_column(@_);
> +  utf8::decode($ret) if utf8::is_utf8($old);
> $self->{_dirty_columns}{$column} = 1
> if (defined $old ^ defined $ret) || (defined $old && $old ne $ret);
> return $ret;
> 
> 
> _______________________________________________
> List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
> Searchable Archive: 
> http://www.grokbase.com/group/dbix-class@lists.rawmode.org

-- 
      Matt S Trout       Need help with your Catalyst or DBIx::Class project?
   Technical Director                    http://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://chainsawblues.vox.com/            http://www.shadowcat.co.uk/servers/



More information about the DBIx-Class mailing list