7 use DBIx::Class::Optional::Dependencies ();
11 my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_SQLANYWHERE_${_}" } qw/DSN USER PASS/};
12 my ($dsn2, $user2, $pass2) = @ENV{map { "DBICTEST_SQLANYWHERE_ODBC_${_}" } qw/DSN USER PASS/};
14 plan skip_all => 'Test needs ' .
15 (join ' and ', map { $_ ? $_ : () }
16 DBIx::Class::Optional::Dependencies->req_missing_for('test_dt'),
17 (join ' or ', map { $_ ? $_ : () }
18 DBIx::Class::Optional::Dependencies->req_missing_for('test_rdbms_sqlanywhere'),
19 DBIx::Class::Optional::Dependencies->req_missing_for('test_rdbms_sqlanywhere_odbc')))
21 DBIx::Class::Optional::Dependencies->req_ok_for ('test_dt') && (
22 $dsn && DBIx::Class::Optional::Dependencies->req_ok_for('test_rdbms_sqlanywhere')
24 $dsn2 && DBIx::Class::Optional::Dependencies->req_ok_for('test_rdbms_sqlanywhere_odbc'))
25 or (not $dsn || $dsn2);
27 if (not ($dsn || $dsn2)) {
28 plan skip_all => <<'EOF';
29 Set $ENV{DBICTEST_SQLANYWHERE_DSN} and/or $ENV{DBICTEST_SQLANYWHERE_ODBC_DSN}
30 _USER and _PASS to run this test'.
31 Warning: This test drops and creates a table called 'event'";
36 [ $dsn, $user, $pass ],
37 [ $dsn2, $user2, $pass2 ],
42 foreach my $info (@info) {
43 my ($dsn, $user, $pass) = @$info;
47 $schema = DBICTest::Schema->clone;
49 $schema->connection($dsn, $user, $pass, {
50 on_connect_call => 'datetime_setup',
53 my $sg = Scope::Guard->new(sub { cleanup($schema) } );
55 eval { $schema->storage->dbh->do('DROP TABLE event') };
56 $schema->storage->dbh->do(<<"SQL");
58 id INT IDENTITY PRIMARY KEY,
69 '2004-08-21 14:36:48.080445',
71 # date only (but minute precision according to ASA docs)
75 '2004-08-21 00:00:00.000000',
79 for my $dt_type (@dt_types) {
80 my ($type, $col, $sample_dt) = @$dt_type;
82 ok(my $dt = $schema->storage->datetime_parser->parse_datetime($sample_dt));
85 ok( $row = $schema->resultset('Event')->create({ $col => $dt, }));
86 ok( $row = $schema->resultset('Event')
87 ->search({ id => $row->id }, { select => [$col] })
90 is( $row->$col, $dt, "$type roundtrip" );
92 is $row->$col->nanosecond, $dt->nanosecond,
93 'nanoseconds survived' if 0+$dt->nanosecond;
102 if (my $dbh = $schema->storage->dbh) {
103 eval { $dbh->do("DROP TABLE $_") } for qw/event/;