Commit | Line | Data |
70350518 |
1 | use strict; |
55087b99 |
2 | use warnings; |
e59c17fe |
3 | |
70350518 |
4 | use Test::More; |
5 | use lib qw(t/lib); |
6 | use DBICTest; |
55087b99 |
7 | use utf8; |
e59c17fe |
8 | |
a47e1233 |
9 | my $schema = DBICTest->init_schema(); |
e59c17fe |
10 | |
404939a4 |
11 | DBICTest::Schema::CD->load_components('UTF8Columns'); |
12 | DBICTest::Schema::CD->utf8_columns('title'); |
70350518 |
13 | Class::C3->reinitialize(); |
14 | |
db087eb1 |
15 | my $cd = $schema->resultset('CD')->create( { artist => 1, title => 'øni', year => '2048' } ); |
70350518 |
16 | my $utf8_char = 'uniuni'; |
e59c17fe |
17 | |
337c98ef |
18 | |
55087b99 |
19 | ok( utf8::is_utf8( $cd->title ), 'got title with utf8 flag' ); |
20 | ok(! utf8::is_utf8( $cd->year ), 'got year without utf8 flag' ); |
337c98ef |
21 | |
55087b99 |
22 | utf8::decode($utf8_char); |
db087eb1 |
23 | $cd->title($utf8_char); |
55087b99 |
24 | ok(! utf8::is_utf8( $cd->{_column_data}{title} ), 'store utf8-less chars' ); |
337c98ef |
25 | |
1d0057bd |
26 | |
27 | my $v_utf8 = "\x{219}"; |
28 | |
29 | $cd->update ({ title => $v_utf8 }); |
30 | $cd->title($v_utf8); |
31 | ok( !$cd->is_column_changed('title'), 'column is not dirty after setting the same unicode value' ); |
32 | |
33 | $cd->update ({ title => $v_utf8 }); |
34 | $cd->title('something_else'); |
35 | ok( $cd->is_column_changed('title'), 'column is dirty after setting to something completely different'); |
db087eb1 |
36 | |
37 | TODO: { |
38 | local $TODO = 'There is currently no way to propagate aliases to inflate_result()'; |
39 | $cd = $schema->resultset('CD')->find ({ title => $v_utf8 }, { select => 'title', as => 'name' }); |
55087b99 |
40 | ok (utf8::is_utf8( $cd->get_column ('name') ), 'utf8 flag propagates via as'); |
db087eb1 |
41 | } |
42 | |
55087b99 |
43 | done_testing; |