8 my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_DB2_${_}" } qw/DSN USER PASS/};
10 #warn "$dsn $user $pass";
12 plan skip_all => 'Set $ENV{DBICTEST_DB2_DSN}, _USER and _PASS to run this test'
13 unless ($dsn && $user);
17 my $schema = DBICTest::Schema->connect($dsn, $user, $pass);
19 my $dbh = $schema->storage->dbh;
21 eval { $dbh->do("DROP TABLE artist") };
23 $dbh->do("CREATE TABLE artist (artistid INTEGER GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), name VARCHAR(255), charfield CHAR(10), rank INTEGER DEFAULT 13);");
25 # This is in core, just testing that it still loads ok
26 $schema->class('Artist')->load_components('PK::Auto');
28 my $ars = $schema->resultset('Artist');
30 # test primary key handling
31 my $new = $ars->create({ name => 'foo' });
32 ok($new->artistid, "Auto-PK worked");
34 my $init_count = $ars->count;
36 $ars->create({ name => 'Artist ' . $_ });
38 is ($ars->count, $init_count + 6, 'Simple count works');
41 my $it = $ars->search( {},
44 order_by => 'artistid'
47 is( $it->count, 3, "LIMIT count ok" );
50 is (@all, 3, 'Number of ->all objects matches count');
53 is( $it->next->name, "foo", "iterator->next ok" );
54 is( $it->next->name, "Artist 1", "iterator->next ok" );
55 is( $it->next->name, "Artist 2", "iterator->next ok" );
56 is( $it->next, undef, "next past end of resultset ok" ); # this can not succeed if @all > 3
59 my $test_type_info = {
61 'data_type' => 'INTEGER',
66 'data_type' => 'VARCHAR',
71 'data_type' => 'CHAR',
76 'data_type' => 'INTEGER',
83 my $type_info = $schema->storage->columns_info_for('artist');
84 is_deeply($type_info, $test_type_info, 'columns_info_for - column data types');
88 my $dbh = eval { $schema->storage->_dbh };
89 $dbh->do("DROP TABLE artist") if $dbh;