10 # use this if you keep a copy of DBD::Sybase linked to FreeTDS somewhere else
12 if (my $lib_dirs = $ENV{DBICTEST_MSSQL_PERL5LIB}) {
13 unshift @INC, $_ for split /:/, $lib_dirs;
17 my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_MSSQL_ODBC_${_}" } qw/DSN USER PASS/};
18 my ($dsn2, $user2, $pass2) = @ENV{map { "DBICTEST_MSSQL_${_}" } qw/DSN USER PASS/};
20 if (not ($dsn || $dsn2)) {
22 'Set $ENV{DBICTEST_MSSQL_ODBC_DSN} and/or $ENV{DBICTEST_MSSQL_DSN} _USER '
23 .'and _PASS to run this test' .
24 "\nWarning: This test drops and creates a table called 'track'";
26 eval "use DateTime; use DateTime::Format::Strptime;";
28 plan skip_all => 'needs DateTime and DateTime::Format::Strptime for testing';
33 [ $dsn, $user, $pass ],
34 [ $dsn2, $user2, $pass2 ],
39 for my $connect_info (@connect_info) {
40 my ($dsn, $user, $pass) = @$connect_info;
44 $schema = DBICTest::Schema->connect($dsn, $user, $pass, {
45 on_connect_call => 'datetime_setup'
48 my $guard = Scope::Guard->new(\&cleanup);
50 # coltype, column, datehash
61 nanosecond => 500000000,
63 ['SMALLDATETIME', # minute precision
74 for my $dt_type (@dt_types) {
75 my ($type, $col, $sample_dt) = @$dt_type;
77 eval { $schema->storage->dbh->do("DROP TABLE track") };
78 $schema->storage->dbh->do(<<"SQL");
80 trackid INT IDENTITY PRIMARY KEY,
86 ok(my $dt = DateTime->new($sample_dt));
89 ok( $row = $schema->resultset('Track')->create({
93 ok( $row = $schema->resultset('Track')
94 ->search({ trackid => $row->trackid }, { select => [$col] })
97 is( $row->$col, $dt, "$type roundtrip" );
99 is( $row->$col->nanosecond, $sample_dt->{nanosecond},
100 'DateTime fractional portion roundtrip' )
101 if exists $sample_dt->{nanosecond};
109 if (my $dbh = eval { $schema->storage->dbh }) {
110 $dbh->do('DROP TABLE track');