5 use DBIx::Class::Optional::Dependencies ();
9 plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('test_rdbms_db2_400')
10 unless DBIx::Class::Optional::Dependencies->req_ok_for ('test_rdbms_db2_400');
12 my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_DB2_400_${_}" } qw/DSN USER PASS/};
14 #warn "$dsn $user $pass";
16 # Probably best to pass the DBQ option in the DSN to specify a specific
17 # libray. Something like:
18 # DBICTEST_DB2_400_DSN='dbi:ODBC:dsn=MyAS400;DBQ=MYLIB'
19 plan skip_all => 'Set $ENV{DBICTEST_DB2_400_DSN}, _USER and _PASS to run this test'
20 unless ($dsn && $user);
24 my $schema = DBICTest::Schema->connect($dsn, $user, $pass);
26 my $dbh = $schema->storage->dbh;
28 eval { $dbh->do("DROP TABLE artist") };
32 artistid INTEGER GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
34 rank INTEGER default 13 not null,
38 # Just to test loading, already in Core
39 $schema->class('Artist')->load_components('PK::Auto');
41 # test primary key handling
42 my $new = $schema->resultset('Artist')->create({ name => 'foo' });
43 ok($new->artistid, "Auto-PK worked");
47 $schema->resultset('Artist')->create({ name => 'Artist ' . $_ });
49 my $it = $schema->resultset('Artist')->search( {},
51 order_by => 'artistid'
54 is( $it->count, 3, "LIMIT count ok" );
55 is( $it->next->name, "foo", "iterator->next ok" );
57 is( $it->next->name, "Artist 2", "iterator->next ok" );
58 is( $it->next, undef, "next past end of resultset ok" );
60 my $test_type_info = {
62 'data_type' => 'INTEGER',
67 'data_type' => 'VARCHAR',
72 'data_type' => 'INTEGER',
77 'data_type' => 'CHAR',
84 my $type_info = $schema->storage->columns_info_for('artist');
85 is_deeply($type_info, $test_type_info, 'columns_info_for - column data types');
89 my $dbh = eval { $schema->storage->_dbh };
90 $dbh->do("DROP TABLE artist") if $dbh;