9 my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_SYBASE_${_}" } qw/DSN USER PASS/};
11 if (not ($dsn && $user)) {
13 'Set $ENV{DBICTEST_SYBASE_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::Sybase;";
18 plan skip_all => 'needs DateTime and DateTime::Format::Sybase for testing';
21 plan tests => (4 * 2 * 2) + 2; # (tests * dt_types * storage_types) + storage_tests
27 'DBI::Sybase::ASE::NoBindVars',
31 for my $storage_type (@storage_types) {
32 $schema = DBICTest::Schema->clone;
34 unless ($storage_type eq 'DBI::Sybase::ASE') { # autodetect
35 $schema->storage_type("::$storage_type");
37 $schema->connection($dsn, $user, $pass, {
39 on_connect_call => [ 'datetime_setup' ],
42 $schema->storage->ensure_connected;
44 isa_ok( $schema->storage, "DBIx::Class::Storage::$storage_type" );
48 ['DATETIME', 'last_updated_at', '2004-08-21T14:36:48.080Z'],
50 ['SMALLDATETIME', 'small_dt', '2004-08-21T14:36:00.000Z'],
53 for my $dt_type (@dt_types) {
54 my ($type, $col, $sample_dt) = @$dt_type;
56 eval { $schema->storage->dbh->do("DROP TABLE track") };
57 $schema->storage->dbh->do(<<"SQL");
59 trackid INT IDENTITY PRIMARY KEY,
65 ok(my $dt = DateTime::Format::Sybase->parse_datetime($sample_dt));
68 ok( $row = $schema->resultset('Track')->create({
72 ok( $row = $schema->resultset('Track')
73 ->search({ trackid => $row->trackid }, { select => [$col] })
76 is( $row->$col, $dt, 'DateTime roundtrip' );
82 if (my $dbh = eval { $schema->storage->_dbh }) {
83 $dbh->do('DROP TABLE track');