6 use DBIx::Class::Optional::Dependencies ();
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 plan skip_all => 'Test needs ' .
14 (join ' and ', map { $_ ? $_ : () }
15 DBIx::Class::Optional::Dependencies->req_missing_for('test_dt'),
16 (join ' or ', map { $_ ? $_ : () }
17 DBIx::Class::Optional::Dependencies->req_missing_for('test_rdbms_sqlanywhere'),
18 DBIx::Class::Optional::Dependencies->req_missing_for('test_rdbms_sqlanywhere_odbc')))
20 DBIx::Class::Optional::Dependencies->req_ok_for ('test_dt') && (
21 $dsn && DBIx::Class::Optional::Dependencies->req_ok_for('test_rdbms_sqlanywhere')
23 $dsn2 && DBIx::Class::Optional::Dependencies->req_ok_for('test_rdbms_sqlanywhere_odbc'))
24 or (not $dsn || $dsn2);
26 if (not ($dsn || $dsn2)) {
27 plan skip_all => <<'EOF';
28 Set $ENV{DBICTEST_SQLANYWHERE_DSN} and/or $ENV{DBICTEST_SQLANYWHERE_ODBC_DSN}
29 _USER and _PASS to run this test'.
30 Warning: This test drops and creates a table called 'event'";
35 [ $dsn, $user, $pass ],
36 [ $dsn2, $user2, $pass2 ],
41 foreach my $info (@info) {
42 my ($dsn, $user, $pass) = @$info;
46 $schema = DBICTest->connect_schema($dsn, $user, $pass, {
47 on_connect_call => 'datetime_setup',
50 my $sg = Scope::Guard->new(sub { cleanup($schema) } );
52 eval { $schema->storage->dbh->do('DROP TABLE event') };
53 $schema->storage->dbh->do(<<"SQL");
55 id INT IDENTITY PRIMARY KEY,
66 '2004-08-21 14:36:48.080445',
68 # date only (but minute precision according to ASA docs)
72 '2004-08-21 00:00:00.000000',
76 for my $dt_type (@dt_types) {
77 my ($type, $col, $sample_dt) = @$dt_type;
79 ok(my $dt = $schema->storage->datetime_parser->parse_datetime($sample_dt));
82 ok( $row = $schema->resultset('Event')->create({ $col => $dt, }));
83 ok( $row = $schema->resultset('Event')
84 ->search({ id => $row->id }, { select => [$col] })
87 is( $row->$col, $dt, "$type roundtrip" );
89 is $row->$col->nanosecond, $dt->nanosecond,
90 'nanoseconds survived' if 0+$dt->nanosecond;
99 if (my $dbh = $schema->storage->dbh) {
100 eval { $dbh->do("DROP TABLE $_") } for qw/event/;