4 my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_DB2_${_}" } qw/DSN USER PASS/};
6 #warn "$dsn $user $pass";
8 plan skip_all, 'Set $ENV{DBICTEST_DB2_DSN}, _USER and _PASS to run this test'
9 unless ($dsn && $user);
13 DBICTest::Schema->compose_connection('DB2Test' => $dsn, $user, $pass);
15 my $dbh = DB2Test->schema->storage->dbh;
18 local $SIG{__WARN__} = sub {};
19 $dbh->do("DROP TABLE artist;");
22 $dbh->do("CREATE TABLE artist (artistid INTEGER GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), name VARCHAR(255), charfield CHAR(10));");
24 #'dbi:mysql:host=localhost;database=dbic_test', 'dbic_test', '');
26 DB2Test::Artist->load_components('PK::Auto');
28 # test primary key handling
29 my $new = DB2Test::Artist->create({ name => 'foo' });
30 ok($new->artistid, "Auto-PK worked");
34 DB2Test::Artist->create({ name => 'Artist ' . $_ });
36 my $it = DB2Test::Artist->search( {},
38 order_by => 'artistid'
41 is( $it->count, 3, "LIMIT count ok" );
42 is( $it->next->name, "foo", "iterator->next ok" );
44 is( $it->next->name, "Artist 2", "iterator->next ok" );
45 is( $it->next, undef, "next past end of resultset ok" );
47 my $test_type_info = {
49 'data_type' => 'INTEGER',
54 'data_type' => 'VARCHAR',
59 'data_type' => 'CHAR',
66 my $type_info = DB2Test->schema->storage->columns_info_for('artist');
67 is_deeply($type_info, $test_type_info, 'columns_info_for - column data types');
72 $dbh->do("DROP TABLE artist");