5 use DBIx::Class::Optional::Dependencies ();
10 plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('test_dt')
12 DBIx::Class::Optional::Dependencies->req_missing_for ('test_rdbms_informix')
13 unless DBIx::Class::Optional::Dependencies->req_ok_for ('test_dt')
14 && DBIx::Class::Optional::Dependencies->req_ok_for ('test_rdbms_informix');
16 my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_INFORMIX_${_}" } qw/DSN USER PASS/};
19 plan skip_all => <<'EOF';
20 Set $ENV{DBICTEST_INFORMIX_DSN} _USER and _PASS to run this test'.
21 Warning: This test drops and creates a table called 'event'";
28 $schema = DBICTest->connect_schema($dsn, $user, $pass, {
29 on_connect_call => [ 'datetime_setup' ],
32 my $sg = Scope::Guard->new(sub { cleanup($schema) } );
34 eval { $schema->storage->dbh->do('DROP TABLE event') };
35 $schema->storage->dbh->do(<<'SQL');
39 created_on DATETIME YEAR TO FRACTION(5)
42 my $rs = $schema->resultset('Event');
44 my $dt = DateTime->now;
45 $dt->set_nanosecond(555640000);
47 my $date_only = DateTime->new(
48 year => $dt->year, month => $dt->month, day => $dt->day
52 ok( $row = $rs->create({
54 starts_at => $date_only,
57 ok( $row = $rs->search({ id => 1 }, { select => [qw/starts_at created_on/] })
60 is $row->created_on, $dt, 'TIMESTAMP as DateTime roundtrip';
62 cmp_ok $row->created_on->nanosecond, '==', $dt->nanosecond,
63 'fractional part of a second survived';
65 is $row->starts_at, $date_only, 'DATE as DateTime roundtrip';
75 $dbh = $schema->storage->dbh;
79 eval { $dbh->do(qq{DROP TABLE $_}) } for qw/event/;