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 'track'";
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);
46 ['TIMESTAMP', 'last_updated_at', '2004-08-21 14:36:48.080445'],
47 # date only (but minute precision according to ASA docs)
48 ['DATE', 'small_dt', '2004-08-21 00:00:00.000000'],
51 for my $dt_type (@dt_types) {
52 my ($type, $col, $sample_dt) = @$dt_type;
54 eval { $schema->storage->dbh->do("DROP TABLE track") };
55 $schema->storage->dbh->do(<<"SQL");
57 trackid INT IDENTITY PRIMARY KEY,
63 ok(my $dt = $schema->storage->datetime_parser->parse_datetime($sample_dt));
66 ok( $row = $schema->resultset('Track')->create({
70 ok( $row = $schema->resultset('Track')
71 ->search({ trackid => $row->trackid }, { select => [$col] })
74 is( $row->$col, $dt, "$type roundtrip" );
76 is $row->$col->nanosecond, $dt->nanosecond,
77 'nanoseconds survived' if 0+$dt->nanosecond;
85 if (my $dbh = $schema->storage->dbh) {
86 eval { $dbh->do("DROP TABLE $_") } for qw/track/;