[Dbix-class] I found a bug under UTF8Column

Tomohiro Hosaka bokutin at bokutin.dyndns.org
Fri Mar 7 14:16:41 GMT 2008


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;




More information about the DBIx-Class mailing list