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 require DBICTest::Schema;
25 my $schema = DBICTest::Schema->connect($dsn, $user, $pass);
27 my $dbh = $schema->storage->dbh;
29 eval { $dbh->do("DROP TABLE artist") };
33 artistid INTEGER GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
35 rank INTEGER default 13 not null,
39 # Just to test loading, already in Core
40 $schema->class('Artist')->load_components('PK::Auto');
42 # test primary key handling
43 my $new = $schema->resultset('Artist')->create({ name => 'foo' });
44 ok($new->artistid, "Auto-PK worked");
48 $schema->resultset('Artist')->create({ name => 'Artist ' . $_ });
50 my $it = $schema->resultset('Artist')->search( {},
52 order_by => 'artistid'
55 is( $it->count, 3, "LIMIT count ok" );
56 is( $it->next->name, "foo", "iterator->next ok" );
58 is( $it->next->name, "Artist 2", "iterator->next ok" );
59 is( $it->next, undef, "next past end of resultset ok" );
61 my $test_type_info = {
63 'data_type' => 'INTEGER',
68 'data_type' => 'VARCHAR',
73 'data_type' => 'INTEGER',
78 'data_type' => 'CHAR',
85 my $type_info = $schema->storage->columns_info_for('artist');
86 is_deeply($type_info, $test_type_info, 'columns_info_for - column data types');
90 my $dbh = eval { $schema->storage->_dbh };
91 $dbh->do("DROP TABLE artist") if $dbh;