10 my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_SYBASE_ASA_${_}" } qw/DSN USER PASS/};
11 my ($dsn2, $user2, $pass2) = @ENV{map { "DBICTEST_SYBASE_ASA_ODBC_${_}" } qw/DSN USER PASS/};
13 if (not ($dsn || $dsn2)) {
14 plan skip_all => <<'EOF';
15 Set $ENV{DBICTEST_SYBASE_ASA_DSN} and/or $ENV{DBICTEST_SYBASE_ASA_ODBC_DSN}
16 _USER and _PASS to run this test'.
17 Warning: This test drops and creates a table called 'track'";
20 eval "use DateTime; use DateTime::Format::Strptime;";
22 plan skip_all => 'needs DateTime and DateTime::Format::Strptime for testing';
27 [ $dsn, $user, $pass ],
28 [ $dsn2, $user2, $pass2 ],
33 foreach my $info (@info) {
34 my ($dsn, $user, $pass) = @$info;
38 $schema = DBICTest::Schema->clone;
40 $schema->connection($dsn, $user, $pass, {
41 on_connect_call => [ 'datetime_setup' ],
44 my $sg = Scope::Guard->new(\&cleanup);
48 ['TIMESTAMP', 'last_updated_at', '2004-08-21 14:36:48.080445'],
49 # date only (but minute precision according to ASA docs)
50 ['DATE', 'small_dt', '2004-08-21 00:00:00.000000'],
53 for my $dt_type (@dt_types) {
54 my ($type, $col, $sample_dt) = @$dt_type;
56 eval { $schema->storage->dbh->do("DROP TABLE track") };
57 $schema->storage->dbh->do(<<"SQL");
59 trackid INT IDENTITY PRIMARY KEY,
65 ok(my $dt = $schema->storage->datetime_parser->parse_datetime($sample_dt));
68 ok( $row = $schema->resultset('Track')->create({
72 ok( $row = $schema->resultset('Track')
73 ->search({ trackid => $row->trackid }, { select => [$col] })
76 is( $row->$col, $dt, "$type roundtrip" );
78 is $row->$col->nanosecond, $dt->nanosecond,
79 'nanoseconds survived' if 0+$dt->nanosecond;
87 if (my $dbh = $schema->storage->dbh) {
88 eval { $dbh->do("DROP TABLE $_") } for qw/track/;