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;
38 nanosecond => 500000000,
40 ['SMALLDATETIME', { # minute precision
49 for my $dt_type (@dt_types) {
50 my ($type, $sample_dt) = @$dt_type;
52 eval { $schema->storage->dbh->do("DROP TABLE track") };
53 $schema->storage->dbh->do(<<"SQL");
55 trackid INT IDENTITY PRIMARY KEY,
58 last_updated_on $type,
61 ok(my $dt = DateTime->new($sample_dt));
64 ok( $row = $schema->resultset('Track')->create({
65 last_updated_on => $dt,
68 ok( $row = $schema->resultset('Track')
69 ->search({ trackid => $row->trackid }, { select => ['last_updated_on'] })
72 is( $row->updated_date, $dt, 'DateTime roundtrip' );
77 if (my $dbh = eval { $schema->storage->_dbh }) {
78 $dbh->do('DROP TABLE track');