7 use DBIx::Class::Storage::DBI::Sybase::DateTime;
9 my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_SYBASE_${_}" } qw/DSN USER PASS/};
11 plan skip_all => 'Set $ENV{DBICTEST_SYBASE_DSN}, _USER and _PASS to run this test'
12 unless ($dsn && $user);
18 'DBI::Sybase::NoBindVars',
22 for my $storage_type (@storage_types) {
23 $schema = DBICTest::Schema->clone;
25 unless ($storage_type eq 'DBI::Sybase') { # autodetect
26 $schema->storage_type("::$storage_type");
28 $schema->connection($dsn, $user, $pass, {AutoCommit => 1});
30 $schema->storage->ensure_connected;
32 isa_ok( $schema->storage, "DBIx::Class::Storage::$storage_type" );
34 $schema->storage->dbh_do (sub {
35 my ($storage, $dbh) = @_;
36 eval { $dbh->do("DROP TABLE artist") };
37 eval { $dbh->do("DROP TABLE track") };
40 artistid INT IDENTITY PRIMARY KEY,
42 rank INT DEFAULT 13 NOT NULL,
43 charfield CHAR(10) NULL
50 trackid INT IDENTITY PRIMARY KEY,
53 last_updated_on DATETIME,
60 # so we start unconnected
61 $schema->storage->disconnect;
63 # test primary key handling
64 my $new = $schema->resultset('Artist')->create({ name => 'foo' });
65 ok($new->artistid > 0, "Auto-PK worked");
67 $seen_id{$new->artistid}++;
71 $new = $schema->resultset('Artist')->create({ name => 'Artist ' . $_ });
72 is ( $seen_id{$new->artistid}, undef, "id for Artist $_ is unique" );
73 $seen_id{$new->artistid}++;
76 my $it = $schema->resultset('Artist')->search( {}, {
78 order_by => 'artistid',
82 local $TODO = 'Sybase is very very fucked in the limit department';
84 is( $it->count, 3, "LIMIT count ok" );
87 is( $it->next->name, "foo", "iterator->next ok" );
89 is( $it->next->name, "Artist 2", "iterator->next ok" );
90 is( $it->next, undef, "next past end of resultset ok" );
93 skip 'quoting bug with NoBindVars', 4
94 if $storage_type eq 'DBI::Sybase::NoBindVars';
96 # Test DateTime inflation
97 ok(my $dt = DBIx::Class::Storage::DBI::Sybase::DateTime
98 ->parse_datetime('2004-08-21T14:36:48.080Z'));
101 ok( $row = $schema->resultset('Track')->create({
102 last_updated_on => $dt,
105 ok( $row = $schema->resultset('Track')
106 ->search({ trackid => $row->trackid }, { select => ['last_updated_on'] })
109 is( $row->updated_date, $dt, 'DateTime inflation works' );
115 if (my $dbh = eval { $schema->storage->_dbh }) {
116 $dbh->do('DROP TABLE artist');
117 $dbh->do('DROP TABLE track');