10 # tests stolen from 749sybase_asa.t
12 my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_FIREBIRD_${_}" } qw/DSN USER PASS/};
13 my ($dsn2, $user2, $pass2) = @ENV{map { "DBICTEST_FIREBIRD_ODBC_${_}" } qw/DSN USER PASS/};
15 plan skip_all => <<'EOF' unless $dsn || $dsn2;
16 Set $ENV{DBICTEST_FIREBIRD_DSN} and/or $ENV{DBICTEST_FIREBIRD_ODBC_DSN},
17 _USER and _PASS to run these tests
21 [ $dsn, $user, $pass ],
22 [ $dsn2, $user2, $pass2 ],
27 foreach my $info (@info) {
28 my ($dsn, $user, $pass) = @$info;
32 $schema = DBICTest::Schema->connect($dsn, $user, $pass);
33 my $dbh = $schema->storage->dbh;
35 my $sg = Scope::Guard->new(\&cleanup);
37 eval { $dbh->do("DROP TABLE artist") };
40 artistid INT PRIMARY KEY,
46 eval { $dbh->do("DROP GENERATOR gen_artist_artistid") };
47 $dbh->do('CREATE GENERATOR gen_artist_artistid');
48 eval { $dbh->do("DROP TRIGGER artist_bi") };
50 CREATE TRIGGER artist_bi FOR artist
51 ACTIVE BEFORE INSERT POSITION 0
54 IF (NEW.artistid IS NULL) THEN
55 NEW.artistid = GEN_ID(gen_artist_artistid,1);
59 my $ars = $schema->resultset('Artist');
60 is ( $ars->count, 0, 'No rows at first' );
62 # test primary key handling
63 my $new = $ars->create({ name => 'foo' });
64 ok($new->artistid, "Auto-PK worked");
66 # test explicit key spec
67 $new = $ars->create ({ name => 'bar', artistid => 66 });
68 is($new->artistid, 66, 'Explicit PK worked');
69 $new->discard_changes;
70 is($new->artistid, 66, 'Explicit PK assigned');
76 push @pop, { name => "Artist_$_" };
78 $ars->populate (\@pop);
81 # test populate with explicit key
85 push @pop, { name => "Artist_expkey_$_", artistid => 100 + $_ };
87 # XXX why does insert_bulk not work here?
88 my @foo = $ars->populate (\@pop);
91 # count what we did so far
92 is ($ars->count, 6, 'Simple count works');
95 my $lim = $ars->search( {},
99 order_by => 'artistid'
102 is( $lim->count, 2, 'ROWS+OFFSET count ok' );
103 is( $lim->all, 2, 'Number of ->all objects matches count' );
107 is( $lim->next->artistid, 101, "iterator->next ok" );
108 is( $lim->next->artistid, 102, "iterator->next ok" );
109 is( $lim->next, undef, "next past end of resultset ok" );
113 local $ars->result_source->column_info('artistid')->{is_auto_increment} = 0;
115 lives_ok { $ars->create({}) }
116 'empty insert works';
119 # test blobs (stolen from 73oracle.t)
121 eval { $dbh->do('DROP TABLE bindtype_test') };
123 CREATE TABLE bindtype_test
128 a_clob BLOB SUB_TYPE TEXT
132 last SKIP; # XXX blob ops cause segfaults!
134 my %binstr = ( 'small' => join('', map { chr($_) } ( 1 .. 127 )) );
135 $binstr{'large'} = $binstr{'small'} x 1024;
137 my $maxloblen = length $binstr{'large'};
138 local $dbh->{'LongReadLen'} = $maxloblen;
140 my $rs = $schema->resultset('BindType');
143 foreach my $type (qw( a_blob a_clob )) {
144 foreach my $size (qw( small large )) {
147 # turn off horrendous binary DBIC_TRACE output
148 local $schema->storage->{debug} = 0;
150 lives_ok { $rs->create( { 'id' => $id, $type => $binstr{$size} } ) }
151 "inserted $size $type without dying";
153 ok($rs->find($id)->$type eq $binstr{$size}, "verified inserted $size $type" );
166 $schema->storage->disconnect; # to avoid object FOO is in use errors
167 $dbh = $schema->storage->dbh;
171 eval { $dbh->do('DROP TRIGGER artist_bi') };
174 eval { $dbh->do('DROP GENERATOR gen_artist_artistid') };
177 foreach my $table (qw/artist bindtype_test/) {
178 eval { $dbh->do("DROP TABLE $table") };