1 BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) }
2 use DBIx::Class::Optional::Dependencies -skip_all_without => qw( ic_dt _rdbms_sqlanywhere_common );
8 use DBIx::Class::_Util 'scope_guard';
12 my @tdeps = qw( test_rdbms_sqlanywhere test_rdbms_sqlanywhere_odbc );
13 plan skip_all => 'Test needs ' . (join ' OR ', map
14 { "[ @{[ DBIx::Class::Optional::Dependencies->req_missing_for( $_ ) ]} ]" }
17 { DBIx::Class::Optional::Dependencies->req_ok_for( $_ ) }
21 my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_SQLANYWHERE_${_}" } qw/DSN USER PASS/};
22 my ($dsn2, $user2, $pass2) = @ENV{map { "DBICTEST_SQLANYWHERE_ODBC_${_}" } qw/DSN USER PASS/};
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 { cleanup($schema) };
44 eval { $schema->storage->dbh->do('DROP TABLE event') };
45 $schema->storage->dbh->do(<<"SQL");
47 id INT IDENTITY PRIMARY KEY,
58 '2004-08-21 14:36:48.080445',
60 # date only (but minute precision according to ASA docs)
64 '2004-08-21 00:00:00.000000',
68 for my $dt_type (@dt_types) {
69 my ($type, $col, $sample_dt) = @$dt_type;
71 ok(my $dt = $schema->storage->datetime_parser->parse_datetime($sample_dt));
74 ok( $row = $schema->resultset('Event')->create({ $col => $dt, }));
75 ok( $row = $schema->resultset('Event')
76 ->search({ id => $row->id }, { select => [$col] })
79 is( $row->$col, $dt, "$type roundtrip" );
81 is $row->$col->nanosecond, $dt->nanosecond,
82 'nanoseconds survived' if 0+$dt->nanosecond;
91 if (my $dbh = $schema->storage->dbh) {
92 eval { $dbh->do("DROP TABLE $_") } for qw/event/;