9 # tests stolen from 748informix.t
11 my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_SYBASE_ASA_${_}" } qw/DSN USER PASS/};
13 plan skip_all => 'Set $ENV{DBICTEST_SYBASE_ASA_DSN}, _USER and _PASS to run this test'
16 my $schema = DBICTest::Schema->connect($dsn, $user, $pass);
18 my $dbh = $schema->storage->dbh;
20 eval { $dbh->do("DROP TABLE artist") };
22 $dbh->do("CREATE TABLE artist (artistid INT IDENTITY PRIMARY KEY, name VARCHAR(255), charfield CHAR(10), rank INT DEFAULT 13)");
24 my $ars = $schema->resultset('Artist');
25 is ( $ars->count, 0, 'No rows at first' );
27 # test primary key handling
28 my $new = $ars->create({ name => 'foo' });
29 ok($new->artistid, "Auto-PK worked");
31 # test explicit key spec
32 $new = $ars->create ({ name => 'bar', artistid => 66 });
33 is($new->artistid, 66, 'Explicit PK worked');
34 $new->discard_changes;
35 is($new->artistid, 66, 'Explicit PK assigned');
41 push @pop, { name => "Artist_$_" };
43 $ars->populate (\@pop);
46 # test populate with explicit key
50 push @pop, { name => "Artist_expkey_$_", artistid => 100 + $_ };
52 $ars->populate (\@pop);
55 # count what we did so far
56 is ($ars->count, 6, 'Simple count works');
59 my $lim = $ars->search( {},
63 order_by => 'artistid'
66 is( $lim->count, 2, 'ROWS+OFFSET count ok' );
67 is( $lim->all, 2, 'Number of ->all objects matches count' );
71 is( $lim->next->artistid, 101, "iterator->next ok" );
72 is( $lim->next->artistid, 102, "iterator->next ok" );
73 is( $lim->next, undef, "next past end of resultset ok" );
75 # test blobs (stolen from 73oracle.t)
76 eval { $dbh->do('DROP TABLE bindtype_test') };
78 CREATE TABLE bindtype_test
80 id INT NOT NULL PRIMARY KEY,
82 blob LONG BINARY NULL,
83 clob LONG VARCHAR NULL
85 ],{ RaiseError => 1, PrintError => 1 });
87 my %binstr = ( 'small' => join('', map { chr($_) } ( 1 .. 127 )) );
88 $binstr{'large'} = $binstr{'small'} x 1024;
90 my $maxloblen = length $binstr{'large'};
91 local $dbh->{'LongReadLen'} = $maxloblen;
93 my $rs = $schema->resultset('BindType');
96 foreach my $type (qw( blob clob )) {
97 foreach my $size (qw( small large )) {
100 lives_ok { $rs->create( { 'id' => $id, $type => $binstr{$size} } ) }
101 "inserted $size $type without dying";
103 ok($rs->find($id)->$type eq $binstr{$size}, "verified inserted $size $type" );
111 my $dbh = eval { $schema->storage->_dbh };
113 $dbh->do("DROP TABLE $_") for qw/artist bindtype_test/;