1use strict; 2use warnings; 3 4use Test::More; 5use Test::Warn; 6use lib qw(t/lib); 7use DBICTest; 8 9warning_like ( 10 sub { 11 package A::Comp; 12 use base 'DBIx::Class'; 13 sub store_column { shift->next::method (@_) }; 14 1; 15 16 package A::Test; 17 use base 'DBIx::Class::Core'; 18 __PACKAGE__->load_components(qw(UTF8Columns +A::Comp)); 19 1; 20 }, 21 qr/Incorrect loading order of DBIx::Class::UTF8Columns.+affect other components overriding store_column \(A::Comp\)/, 22 'incorrect order warning issued', 23); 24 25my $schema = DBICTest->init_schema(); 26DBICTest::Schema::CD->load_components('UTF8Columns'); 27DBICTest::Schema::CD->utf8_columns('title'); 28Class::C3->reinitialize(); 29 30my $cd = $schema->resultset('CD')->create( { artist => 1, title => "weird\x{466}stuff", year => '2048' } ); 31 32ok( utf8::is_utf8( $cd->title ), 'got title with utf8 flag' ); 33ok(! utf8::is_utf8( $cd->{_column_data}{title} ), 'store title without utf8' ); 34 35ok(! utf8::is_utf8( $cd->year ), 'got year without utf8 flag' ); 36ok(! utf8::is_utf8( $cd->{_column_data}{year} ), 'store year without utf8' ); 37 38$cd->title('nonunicode'); 39ok(! utf8::is_utf8( $cd->title ), 'got title without utf8 flag' ); 40ok(! utf8::is_utf8( $cd->{_column_data}{title} ), 'store utf8-less chars' ); 41 42 43my $v_utf8 = "\x{219}"; 44 45$cd->update ({ title => $v_utf8 }); 46$cd->title($v_utf8); 47ok( !$cd->is_column_changed('title'), 'column is not dirty after setting the same unicode value' ); 48 49$cd->update ({ title => $v_utf8 }); 50$cd->title('something_else'); 51ok( $cd->is_column_changed('title'), 'column is dirty after setting to something completely different'); 52 53TODO: { 54 local $TODO = 'There is currently no way to propagate aliases to inflate_result()'; 55 $cd = $schema->resultset('CD')->find ({ title => $v_utf8 }, { select => 'title', as => 'name' }); 56 ok (utf8::is_utf8( $cd->get_column ('name') ), 'utf8 flag propagates via as'); 57} 58 59done_testing; 60