10 my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_SQLANYWHERE_${_}" } qw/DSN USER PASS/};
11 my ($dsn2, $user2, $pass2) = @ENV{map { "DBICTEST_SQLANYWHERE_ODBC_${_}" } qw/DSN USER PASS/};
13 if (not ($dsn || $dsn2)) {
14 plan skip_all => <<'EOF';
15 Set $ENV{DBICTEST_SQLANYWHERE_DSN} and/or $ENV{DBICTEST_SQLANYWHERE_ODBC_DSN}
16 _USER and _PASS to run this test'.
17 Warning: This test drops and creates a table called 'event'";
21 plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('test_dt')
22 unless DBIx::Class::Optional::Dependencies->req_ok_for ('test_dt');
25 [ $dsn, $user, $pass ],
26 [ $dsn2, $user2, $pass2 ],
31 foreach my $info (@info) {
32 my ($dsn, $user, $pass) = @$info;
36 $schema = DBICTest::Schema->clone;
38 $schema->connection($dsn, $user, $pass, {
39 on_connect_call => 'datetime_setup',
42 my $sg = Scope::Guard->new(\&cleanup);
44 eval { $schema->storage->dbh->do('DROP TABLE event') };
45 $schema->storage->dbh->do(<<"SQL");
47 id INT IDENTITY PRIMARY KEY,
58 '2004-08-21 14:36:48.080445',
60 # date only (but minute precision according to ASA docs)
64 '2004-08-21 00:00:00.000000',
68 for my $dt_type (@dt_types) {
69 my ($type, $col, $sample_dt) = @$dt_type;
71 ok(my $dt = $schema->storage->datetime_parser->parse_datetime($sample_dt));
74 ok( $row = $schema->resultset('Event')->create({ $col => $dt, }));
75 ok( $row = $schema->resultset('Event')
76 ->search({ id => $row->id }, { select => [$col] })
79 is( $row->$col, $dt, "$type roundtrip" );
81 is $row->$col->nanosecond, $dt->nanosecond,
82 'nanoseconds survived' if 0+$dt->nanosecond;
90 if (my $dbh = $schema->storage->dbh) {
91 eval { $dbh->do("DROP TABLE $_") } for qw/event/;