9 my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_SYBASE_ASA_${_}" } qw/DSN USER PASS/};
10 my ($dsn2, $user2, $pass2) = @ENV{map { "DBICTEST_SYBASE_ASA_ODBC_${_}" } qw/DSN USER PASS/};
12 if (not ($dsn || $dsn2)) {
13 plan skip_all => <<'EOF';
14 Set $ENV{DBICTEST_SYBASE_ASA_DSN} and/or $ENV{DBICTEST_SYBASE_ASA_ODBC_DSN}
15 _USER and _PASS to run this test'.
16 Warning: This test drops and creates a table called 'track'";
19 eval "use DateTime; use DateTime::Format::Strptime;";
21 plan skip_all => 'needs DateTime and DateTime::Format::Strptime for testing';
26 [ $dsn, $user, $pass ],
27 [ $dsn2, $user2, $pass2 ],
32 foreach my $info (@info) {
33 my ($dsn, $user, $pass) = @$info;
37 my $schema = DBICTest::Schema->clone;
39 $schema->connection($dsn, $user, $pass, {
40 on_connect_call => [ 'datetime_setup' ],
43 push @handles_to_clean, $schema->storage->dbh;
47 ['TIMESTAMP', 'last_updated_at', '2004-08-21 14:36:48.080445'],
48 # date only (but minute precision according to ASA docs)
49 ['DATE', 'small_dt', '2004-08-21 00:00:00.000000'],
52 for my $dt_type (@dt_types) {
53 my ($type, $col, $sample_dt) = @$dt_type;
55 eval { $schema->storage->dbh->do("DROP TABLE track") };
56 $schema->storage->dbh->do(<<"SQL");
58 trackid INT IDENTITY PRIMARY KEY,
64 ok(my $dt = $schema->storage->datetime_parser->parse_datetime($sample_dt));
67 ok( $row = $schema->resultset('Track')->create({
71 ok( $row = $schema->resultset('Track')
72 ->search({ trackid => $row->trackid }, { select => [$col] })
75 is( $row->$col, $dt, 'DateTime roundtrip' );
77 is $row->$col->nanosecond, $dt->nanosecond,
78 'nanoseconds survived' if 0+$dt->nanosecond;
86 foreach my $dbh (@handles_to_clean) {
87 eval { $dbh->do("DROP TABLE $_") } for qw/track/;