9 # tests stolen from 748informix.t
11 my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_SYBASE_ASA_${_}" } qw/DSN USER PASS/};
12 my ($dsn2, $user2, $pass2) = @ENV{map { "DBICTEST_SYBASE_ASA_ODBC_${_}" } qw/DSN USER PASS/};
14 plan skip_all => <<"EOF" unless $dsn || $dsn2;
15 Set $ENV{DBICTEST_SYBASE_ASA_DSN} and/or $ENV{DBICTEST_SYBASE_ASA_ODBC_DSN},
16 _USER and _PASS to run these tests
20 [ $dsn, $user, $pass ],
21 [ $dsn2, $user2, $pass2 ],
26 foreach my $info (@info) {
27 my ($dsn, $user, $pass) = @$info;
31 my $schema = DBICTest::Schema->connect($dsn, $user, $pass);
33 my $dbh = $schema->storage->dbh;
35 push @handles_to_clean, $dbh;
37 eval { $dbh->do("DROP TABLE artist") };
41 artistid INT IDENTITY PRIMARY KEY,
42 name VARCHAR(255) NULL,
43 charfield CHAR(10) NULL,
48 my $ars = $schema->resultset('Artist');
49 is ( $ars->count, 0, 'No rows at first' );
51 # test primary key handling
52 my $new = $ars->create({ name => 'foo' });
53 ok($new->artistid, "Auto-PK worked");
55 # test explicit key spec
56 $new = $ars->create ({ name => 'bar', artistid => 66 });
57 is($new->artistid, 66, 'Explicit PK worked');
58 $new->discard_changes;
59 is($new->artistid, 66, 'Explicit PK assigned');
65 push @pop, { name => "Artist_$_" };
67 $ars->populate (\@pop);
70 # test populate with explicit key
74 push @pop, { name => "Artist_expkey_$_", artistid => 100 + $_ };
76 $ars->populate (\@pop);
79 # count what we did so far
80 is ($ars->count, 6, 'Simple count works');
83 my $lim = $ars->search( {},
87 order_by => 'artistid'
90 is( $lim->count, 2, 'ROWS+OFFSET count ok' );
91 is( $lim->all, 2, 'Number of ->all objects matches count' );
95 is( $lim->next->artistid, 101, "iterator->next ok" );
96 is( $lim->next->artistid, 102, "iterator->next ok" );
97 is( $lim->next, undef, "next past end of resultset ok" );
101 local $ars->result_source->column_info('artistid')->{is_auto_increment} = 0;
103 lives_ok { $ars->create({}) }
104 'empty insert works';
107 # test blobs (stolen from 73oracle.t)
108 eval { $dbh->do('DROP TABLE bindtype_test') };
110 CREATE TABLE bindtype_test
112 id INT NOT NULL PRIMARY KEY,
114 blob LONG BINARY NULL,
115 clob LONG VARCHAR NULL
117 ],{ RaiseError => 1, PrintError => 1 });
119 my %binstr = ( 'small' => join('', map { chr($_) } ( 1 .. 127 )) );
120 $binstr{'large'} = $binstr{'small'} x 1024;
122 my $maxloblen = length $binstr{'large'};
123 local $dbh->{'LongReadLen'} = $maxloblen;
125 my $rs = $schema->resultset('BindType');
128 foreach my $type (qw( blob clob )) {
129 foreach my $size (qw( small large )) {
132 # turn off horrendous binary DBIC_TRACE output
133 local $schema->storage->{debug} = 0;
135 lives_ok { $rs->create( { 'id' => $id, $type => $binstr{$size} } ) }
136 "inserted $size $type without dying";
138 ok($rs->find($id)->$type eq $binstr{$size}, "verified inserted $size $type" );
147 foreach my $dbh (@handles_to_clean) {
148 eval { $dbh->do("DROP TABLE $_") } for qw/artist bindtype_test/;