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);
16 { # Fake storage driver for mysql + no bind variables
17 package DBIx::Class::Storage::DBI::MySQLNoBindVars;
20 DBIx::Class::Storage::DBI::NoBindVars
21 DBIx::Class::Storage::DBI::mysql
23 $INC{'DBIx/Class/Storage/DBI/MySQLNoBindVars.pm'} = 1;
26 # XXX Class::C3 doesn't like some of the Storage stuff happening late...
27 Class::C3::reinitialize();
29 my $schema = DBICTest::Schema->clone;
30 $schema->storage_type('::DBI::MySQLNoBindVars');
31 $schema->connection($dsn, $user, $pass);
33 my $dbh = $schema->storage->dbh;
35 $dbh->do("DROP TABLE IF EXISTS artist;");
37 $dbh->do("CREATE TABLE artist (artistid INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, name VARCHAR(100), rank INTEGER NOT NULL DEFAULT '13', charfield CHAR(10));");
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( {},
52 order_by => 'artistid' }
54 is( $it->count, 3, "LIMIT count ok" ); # ask for 3 rows out of 7 artists
55 is( $it->next->name, "Artist 2", "iterator->next ok" );
58 is( $it->next, undef, "next past end of resultset ok" );
62 my $dbh = eval { $schema->storage->_dbh };
63 $dbh->do("DROP TABLE artist") if $dbh;