9 # tests stolen from 749sybase_asa.t
11 my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_FIREBIRD_${_}" } qw/DSN USER PASS/};
12 my ($dsn2, $user2, $pass2) = @ENV{map { "DBICTEST_FIREBIRD_ODBC_${_}" } qw/DSN USER PASS/};
14 plan skip_all => <<'EOF' unless $dsn || $dsn2;
15 Set $ENV{DBICTEST_FIREBIRD_DSN} and/or $ENV{DBICTEST_FIREBIRD_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 PRIMARY KEY,
47 $dbh->do('CREATE GENERATOR gen_artist_artistid');
49 CREATE TRIGGER artist_bi FOR artist
50 ACTIVE BEFORE INSERT POSITION 0
53 IF (NEW.artistid IS NULL) THEN
54 NEW.artistid = GEN_ID(gen_artist_artistid,1);
58 my $ars = $schema->resultset('Artist');
59 is ( $ars->count, 0, 'No rows at first' );
61 # test primary key handling
62 my $new = $ars->create({ name => 'foo' });
63 ok($new->artistid, "Auto-PK worked");
65 # test explicit key spec
66 $new = $ars->create ({ name => 'bar', artistid => 66 });
67 is($new->artistid, 66, 'Explicit PK worked');
68 $new->discard_changes;
69 is($new->artistid, 66, 'Explicit PK assigned');
75 push @pop, { name => "Artist_$_" };
77 $ars->populate (\@pop);
80 # test populate with explicit key
84 push @pop, { name => "Artist_expkey_$_", artistid => 100 + $_ };
86 $ars->populate (\@pop);
89 # count what we did so far
90 is ($ars->count, 6, 'Simple count works');
93 my $lim = $ars->search( {},
97 order_by => 'artistid'
100 is( $lim->count, 2, 'ROWS+OFFSET count ok' );
101 is( $lim->all, 2, 'Number of ->all objects matches count' );
105 is( $lim->next->artistid, 101, "iterator->next ok" );
106 is( $lim->next->artistid, 102, "iterator->next ok" );
107 is( $lim->next, undef, "next past end of resultset ok" );
111 local $ars->result_source->column_info('artistid')->{is_auto_increment} = 0;
113 lives_ok { $ars->create({}) }
114 'empty insert works';
117 # test blobs (stolen from 73oracle.t)
118 eval { $dbh->do('DROP TABLE bindtype_test') };
120 CREATE TABLE bindtype_test
122 id INT NOT NULL PRIMARY KEY,
129 my %binstr = ( 'small' => join('', map { chr($_) } ( 1 .. 127 )) );
130 $binstr{'large'} = $binstr{'small'} x 1024;
132 my $maxloblen = length $binstr{'large'};
133 local $dbh->{'LongReadLen'} = $maxloblen;
135 my $rs = $schema->resultset('BindType');
138 foreach my $type (qw( blob clob )) {
139 foreach my $size (qw( small large )) {
142 # turn off horrendous binary DBIC_TRACE output
143 local $schema->storage->{debug} = 0;
145 lives_ok { $rs->create( { 'id' => $id, $type => $binstr{$size} } ) }
146 "inserted $size $type without dying";
148 ok($rs->find($id)->$type eq $binstr{$size}, "verified inserted $size $type" );
157 foreach my $dbh (@handles_to_clean) {
158 eval { $dbh->do("DROP TABLE $_") } for qw/artist bindtype_test/;