7 use DBI::Const::GetInfoType;
9 my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_MYSQL_${_}" } qw/DSN USER PASS/};
11 #warn "$dsn $user $pass";
13 plan skip_all => 'Set $ENV{DBICTEST_MYSQL_DSN}, _USER and _PASS to run this test'
14 unless ($dsn && $user);
18 DBICTest::Schema->compose_connection('MySQLTest' => $dsn, $user, $pass);
20 my $dbh = MySQLTest->schema->storage->dbh;
22 $dbh->do("DROP TABLE IF EXISTS artist;");
24 $dbh->do("CREATE TABLE artist (artistid INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, name VARCHAR(255), charfield CHAR(10));");
26 #'dbi:mysql:host=localhost;database=dbic_test', 'dbic_test', '');
28 MySQLTest::Artist->load_components('PK::Auto');
30 # test primary key handling
31 my $new = MySQLTest::Artist->create({ name => 'foo' });
32 ok($new->artistid, "Auto-PK worked");
36 MySQLTest::Artist->create({ name => 'Artist ' . $_ });
38 my $it = MySQLTest::Artist->search( {},
41 order_by => 'artistid' }
43 is( $it->count, 3, "LIMIT count ok" );
44 is( $it->next->name, "Artist 2", "iterator->next ok" );
47 is( $it->next, undef, "next past end of resultset ok" );
49 my $test_type_info = {
54 'default_value' => undef,
57 'data_type' => 'VARCHAR',
60 'default_value' => undef,
63 'data_type' => 'CHAR',
66 'default_value' => undef,
71 my $mysql_version = $dbh->get_info( $GetInfoType{SQL_DBMS_VER} );
72 skip "Cannot determine MySQL server version", 1 if !$mysql_version;
74 my ($v1, $v2, $v3) = $mysql_version =~ /^(\d+)\.(\d+)(?:\.(\d+))?/;
75 skip "Cannot determine MySQL server version", 1 if !$v1 || !defined($v2);
79 if( ($v1 < 5) || ($v1 == 5 && $v2 == 0 && $v3 <= 3) ) {
80 $test_type_info->{charfield}->{data_type} = 'VARCHAR';
83 my $type_info = MySQLTest->schema->storage->columns_info_for('artist');
84 is_deeply($type_info, $test_type_info, 'columns_info_for - column data types');
88 $dbh->do("DROP TABLE artist");