9 my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_MSSQL_ODBC_${_}" } qw/DSN USER PASS/};
11 if (not ($dsn && $user)) {
13 'Set $ENV{DBICTEST_MSSQL_ODBC_DSN}, _USER and _PASS to run this test' .
14 "\nWarning: This test drops and creates a table called 'track'";
16 eval "use DateTime; use DateTime::Format::Strptime;";
18 plan skip_all => 'needs DateTime and DateTime::Format::Strptime for testing';
21 plan tests => 4 * 2; # (tests * dt_types)
25 my $schema = DBICTest::Schema->clone;
27 $schema->connection($dsn, $user, $pass);
28 $schema->storage->ensure_connected;
30 # coltype, column, datehash
41 nanosecond => 500000000,
43 ['SMALLDATETIME', # minute precision
54 for my $dt_type (@dt_types) {
55 my ($type, $col, $sample_dt) = @$dt_type;
57 eval { $schema->storage->dbh->do("DROP TABLE track") };
58 $schema->storage->dbh->do(<<"SQL");
60 trackid INT IDENTITY PRIMARY KEY,
66 ok(my $dt = DateTime->new($sample_dt));
69 ok( $row = $schema->resultset('Track')->create({
73 ok( $row = $schema->resultset('Track')
74 ->search({ trackid => $row->trackid }, { select => [$col] })
77 is( $row->$col, $dt, 'DateTime roundtrip' );
82 if (my $dbh = eval { $schema->storage->_dbh }) {
83 $dbh->do('DROP TABLE track');