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") };
24 artistid INT IDENTITY PRIMARY KEY,
25 name VARCHAR(255) NULL,
26 charfield CHAR(10) NULL,
31 my $ars = $schema->resultset('Artist');
32 is ( $ars->count, 0, 'No rows at first' );
34 # test primary key handling
35 my $new = $ars->create({ name => 'foo' });
36 ok($new->artistid, "Auto-PK worked");
38 # test explicit key spec
39 $new = $ars->create ({ name => 'bar', artistid => 66 });
40 is($new->artistid, 66, 'Explicit PK worked');
41 $new->discard_changes;
42 is($new->artistid, 66, 'Explicit PK assigned');
48 push @pop, { name => "Artist_$_" };
50 $ars->populate (\@pop);
53 # test populate with explicit key
57 push @pop, { name => "Artist_expkey_$_", artistid => 100 + $_ };
59 $ars->populate (\@pop);
62 # count what we did so far
63 is ($ars->count, 6, 'Simple count works');
66 my $lim = $ars->search( {},
70 order_by => 'artistid'
73 is( $lim->count, 2, 'ROWS+OFFSET count ok' );
74 is( $lim->all, 2, 'Number of ->all objects matches count' );
78 is( $lim->next->artistid, 101, "iterator->next ok" );
79 is( $lim->next->artistid, 102, "iterator->next ok" );
80 is( $lim->next, undef, "next past end of resultset ok" );
84 local $ars->result_source->column_info('artistid')->{is_auto_increment} = 0;
86 lives_ok { $ars->create({}) }
90 # test blobs (stolen from 73oracle.t)
91 eval { $dbh->do('DROP TABLE bindtype_test') };
93 CREATE TABLE bindtype_test
95 id INT NOT NULL PRIMARY KEY,
97 blob LONG BINARY NULL,
98 clob LONG VARCHAR NULL
100 ],{ RaiseError => 1, PrintError => 1 });
102 my %binstr = ( 'small' => join('', map { chr($_) } ( 1 .. 127 )) );
103 $binstr{'large'} = $binstr{'small'} x 1024;
105 my $maxloblen = length $binstr{'large'};
106 local $dbh->{'LongReadLen'} = $maxloblen;
108 my $rs = $schema->resultset('BindType');
111 foreach my $type (qw( blob clob )) {
112 foreach my $size (qw( small large )) {
115 # turn off horrendous binary DBIC_TRACE output
116 local $schema->storage->{debug} = 0;
118 lives_ok { $rs->create( { 'id' => $id, $type => $binstr{$size} } ) }
119 "inserted $size $type without dying";
121 ok($rs->find($id)->$type eq $binstr{$size}, "verified inserted $size $type" );
129 if (my $dbh = eval { $schema->storage->_dbh }) {
130 $dbh->do("DROP TABLE $_") for qw/artist bindtype_test/;