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