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; |
e59c17fe |
8 | |
7146f619 |
9 | warning_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 | ); |
d38cd95c |
24 | |
a47e1233 |
25 | my $schema = DBICTest->init_schema(); |
404939a4 |
26 | DBICTest::Schema::CD->load_components('UTF8Columns'); |
27 | DBICTest::Schema::CD->utf8_columns('title'); |
70350518 |
28 | Class::C3->reinitialize(); |
29 | |
a786c458 |
30 | my $cd = $schema->resultset('CD')->create( { artist => 1, title => "weird\x{466}stuff", year => '2048' } ); |
337c98ef |
31 | |
55087b99 |
32 | ok( utf8::is_utf8( $cd->title ), 'got title with utf8 flag' ); |
a786c458 |
33 | ok(! utf8::is_utf8( $cd->{_column_data}{title} ), 'store title without utf8' ); |
34 | |
55087b99 |
35 | ok(! utf8::is_utf8( $cd->year ), 'got year without utf8 flag' ); |
a786c458 |
36 | ok(! utf8::is_utf8( $cd->{_column_data}{year} ), 'store year without utf8' ); |
337c98ef |
37 | |
a786c458 |
38 | $cd->title('nonunicode'); |
39 | ok(! utf8::is_utf8( $cd->title ), 'got title without utf8 flag' ); |
55087b99 |
40 | ok(! utf8::is_utf8( $cd->{_column_data}{title} ), 'store utf8-less chars' ); |
337c98ef |
41 | |
1d0057bd |
42 | |
43 | my $v_utf8 = "\x{219}"; |
44 | |
45 | $cd->update ({ title => $v_utf8 }); |
46 | $cd->title($v_utf8); |
47 | ok( !$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'); |
51 | ok( $cd->is_column_changed('title'), 'column is dirty after setting to something completely different'); |
db087eb1 |
52 | |
53 | TODO: { |
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' }); |
55087b99 |
56 | ok (utf8::is_utf8( $cd->get_column ('name') ), 'utf8 flag propagates via as'); |
db087eb1 |
57 | } |
58 | |
55087b99 |
59 | done_testing; |