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'";
27 plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('test_dt')
28 unless DBIx::Class::Optional::Dependencies->req_ok_for ('test_dt');
31 [ $dsn, $user, $pass ],
32 [ $dsn2, $user2, $pass2 ],
38 for my $connect_info (@connect_info) {
39 my ($dsn, $user, $pass) = @$connect_info;
43 $schema = DBICTest::Schema->connect($dsn, $user, $pass, {
44 on_connect_call => 'datetime_setup'
49 local $SIG{__WARN__} = sub { $w = shift };
50 $schema->storage->ensure_connected;
51 if ($w =~ /Your DBD::Sybase is too old to support DBIx::Class::InflateColumn::DateTime/) {
52 skip "Skipping tests on old DBD::Sybase " . DBD::Sybase->VERSION, 1;
56 my $guard = Scope::Guard->new(\&cleanup);
58 # coltype, column, datehash
69 nanosecond => 500000000,
71 ['SMALLDATETIME', # minute precision
82 for my $dt_type (@dt_types) {
83 my ($type, $col, $sample_dt) = @$dt_type;
85 eval { $schema->storage->dbh->do("DROP TABLE track") };
86 $schema->storage->dbh->do(<<"SQL");
88 trackid INT IDENTITY PRIMARY KEY,
94 ok(my $dt = DateTime->new($sample_dt));
97 ok( $row = $schema->resultset('Track')->create({
101 ok( $row = $schema->resultset('Track')
102 ->search({ trackid => $row->trackid }, { select => [$col] })
105 is( $row->$col, $dt, "$type roundtrip" );
107 cmp_ok( $row->$col->nanosecond, '==', $sample_dt->{nanosecond},
108 'DateTime fractional portion roundtrip' )
109 if exists $sample_dt->{nanosecond};
117 if (my $dbh = eval { $schema->storage->dbh }) {
118 $dbh->do('DROP TABLE track');