9 my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_INFORMIX_${_}" } qw/DSN USER PASS/};
11 #warn "$dsn $user $pass";
13 plan skip_all => 'Set $ENV{DBICTEST_INFORMIX_DSN}, _USER and _PASS to run this test'
16 my $schema = DBICTest::Schema->connect($dsn, $user, $pass, {
20 my $dbh = $schema->storage->dbh;
22 eval { $dbh->do("DROP TABLE artist") };
24 $dbh->do("CREATE TABLE artist (artistid SERIAL, name VARCHAR(255), charfield CHAR(10), rank INTEGER DEFAULT 13);");
26 my $ars = $schema->resultset('Artist');
27 is ( $ars->count, 0, 'No rows at first' );
29 # test primary key handling
30 my $new = $ars->create({ name => 'foo' });
31 ok($new->artistid, "Auto-PK worked");
33 # test explicit key spec
34 $new = $ars->create ({ name => 'bar', artistid => 66 });
35 is($new->artistid, 66, 'Explicit PK worked');
36 $new->discard_changes;
37 is($new->artistid, 66, 'Explicit PK assigned');
43 push @pop, { name => "Artist_$_" };
45 $ars->populate (\@pop);
48 # test populate with explicit key
52 push @pop, { name => "Artist_expkey_$_", artistid => 100 + $_ };
54 $ars->populate (\@pop);
57 # count what we did so far
58 is ($ars->count, 6, 'Simple count works');
61 my $lim = $ars->search( {},
65 order_by => 'artistid'
68 is( $lim->count, 2, 'ROWS+OFFSET count ok' );
69 is( $lim->all, 2, 'Number of ->all objects matches count' );
73 is( $lim->next->artistid, 101, "iterator->next ok" );
74 is( $lim->next->artistid, 102, "iterator->next ok" );
75 is( $lim->next, undef, "next past end of resultset ok" );
82 $ars->create({ name => 'in_savepoint' });
83 die "rolling back savepoint";
86 ok ((not $ars->search({ name => 'in_savepoint' })->first),
87 'savepoint rolled back');
88 $ars->create({ name => 'in_outer_txn' });
89 die "rolling back outer txn";
93 like $@, qr/rolling back outer txn/,
94 'correct exception for rollback';
96 ok ((not $ars->search({ name => 'in_outer_txn' })->first),
97 'outer txn rolled back');
103 my $dbh = eval { $schema->storage->_dbh };
104 $dbh->do("DROP TABLE artist") if $dbh;