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 ],
40 for my $connect_info (@connect_info) {
41 my ($dsn, $user, $pass) = @$connect_info;
45 $schema = DBICTest::Schema->connect($dsn, $user, $pass, {
46 on_connect_call => 'datetime_setup'
51 local $SIG{__WARN__} = sub { $w = shift };
52 $schema->storage->ensure_connected;
53 if ($w =~ /Your DBD::Sybase is too old to support DBIx::Class::InflateColumn::DateTime/) {
54 skip "Skipping tests on old DBD::Sybase " . DBD::Sybase->VERSION, 1;
58 my $guard = Scope::Guard->new(\&cleanup);
60 # coltype, column, datehash
71 nanosecond => 500000000,
73 ['SMALLDATETIME', # minute precision
84 for my $dt_type (@dt_types) {
85 my ($type, $col, $sample_dt) = @$dt_type;
87 eval { $schema->storage->dbh->do("DROP TABLE track") };
88 $schema->storage->dbh->do(<<"SQL");
90 trackid INT IDENTITY PRIMARY KEY,
96 ok(my $dt = DateTime->new($sample_dt));
99 ok( $row = $schema->resultset('Track')->create({
103 ok( $row = $schema->resultset('Track')
104 ->search({ trackid => $row->trackid }, { select => [$col] })
107 is( $row->$col, $dt, "$type roundtrip" );
109 cmp_ok( $row->$col->nanosecond, '==', $sample_dt->{nanosecond},
110 'DateTime fractional portion roundtrip' )
111 if exists $sample_dt->{nanosecond};
119 if (my $dbh = eval { $schema->storage->dbh }) {
120 $dbh->do('DROP TABLE track');