1 use DBIx::Class::Optional::Dependencies -skip_all_without => qw( ic_dt cdbicompat );
10 my $schema = DBICTest->init_schema();
12 DBICTest::Schema::CD->load_components(qw/CDBICompat::Relationships/);
14 DBICTest::Schema::CD->has_a( 'year', 'DateTime',
15 inflate => sub { DateTime->new( year => shift ) },
16 deflate => sub { shift->year }
18 Class::C3->reinitialize if DBIx::Class::_ENV_::OLD_MRO;
21 my $cd = $schema->resultset("CD")->find(3);
23 is( ref($cd->year), 'DateTime', 'year is a DateTime, ok' );
25 is( $cd->year->month, 1, 'inflated month ok' );
28 my $now = DateTime->now;
32 ($cd) = $schema->resultset("CD")->search({ year => $now->year });
33 is( $cd->year->year, $now->year, 'deflate ok' );
35 # re-test using alternate deflate syntax
36 $schema->class("CD")->has_a( 'year', 'DateTime',
37 inflate => sub { DateTime->new( year => shift ) },
42 $cd = $schema->resultset("CD")->find(3);
44 is( ref($cd->year), 'DateTime', 'year is a DateTime, ok' );
46 is( $cd->year->month, 1, 'inflated month ok' );
53 ($cd) = $schema->resultset("CD")->search({ year => $now->year });
54 is( $cd->year->year, $now->year, 'deflate ok' );