5 use DBIx::Class::Optional::Dependencies ();
11 DBICTEST_FIREBIRD => 'test_rdbms_firebird',
12 DBICTEST_FIREBIRD_INTERBASE => 'test_rdbms_firebird_interbase',
13 DBICTEST_FIREBIRD_ODBC => 'test_rdbms_firebird_odbc',
16 plan skip_all => join (' ',
17 'Set $ENV{DBICTEST_FIREBIRD_DSN} and/or $ENV{DBICTEST_FIREBIRD_INTERBASE_DSN}',
18 'and/or $ENV{DBICTEST_FIREBIRD_ODBC_DSN},',
19 '_USER and _PASS to run these tests.',
21 "WARNING: This test drops and creates a table called 'event'",
22 ) unless grep { $ENV{"${_}_DSN"} } keys %$env2optdep;
24 plan skip_all => ( 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for('test_dt') )
25 unless DBIx::Class::Optional::Dependencies->req_ok_for ('test_dt');
29 for my $prefix (keys %$env2optdep) { SKIP: {
31 my ($dsn, $user, $pass) = map { $ENV{"${prefix}_$_"} } qw/DSN USER PASS/;
35 note "Testing with ${prefix}_DSN";
37 skip ("Testing with ${prefix}_DSN needs " . DBIx::Class::Optional::Dependencies->req_missing_for( $env2optdep->{$prefix} ), 1)
38 unless DBIx::Class::Optional::Dependencies->req_ok_for($env2optdep->{$prefix});
40 $schema = DBICTest->connect_schema($dsn, $user, $pass, {
43 on_connect_call => [ 'datetime_setup' ],
46 my $sg = Scope::Guard->new(sub { cleanup($schema) } );
48 eval { $schema->storage->dbh->do('DROP TABLE "event"') };
49 $schema->storage->dbh->do(<<'SQL');
50 CREATE TABLE "event" (
53 "created_on" TIMESTAMP
56 my $rs = $schema->resultset('Event');
58 my $dt = DateTime->now;
59 $dt->set_nanosecond(555600000);
61 my $date_only = DateTime->new(
62 year => $dt->year, month => $dt->month, day => $dt->day
66 ok( $row = $rs->create({
68 starts_at => $date_only,
71 ok( $row = $rs->search({ id => 1 }, { select => [qw/starts_at created_on/] })
74 is $row->created_on, $dt, 'TIMESTAMP as DateTime roundtrip';
76 cmp_ok $row->created_on->nanosecond, '==', $dt->nanosecond,
77 'fractional part of a second survived';
79 is $row->starts_at, $date_only, 'DATE as DateTime roundtrip';
89 $schema->storage->disconnect; # to avoid object FOO is in use errors
90 $dbh = $schema->storage->dbh;
94 eval { $dbh->do(qq{DROP TABLE "$_"}) } for qw/event/;