error handling cleanup for _execute, etc
[dbsrgits/DBIx-Class.git] / t / 93nobindvars.t
CommitLineData
d5130dd2 1use strict;
2use warnings;
3
4# Copied from 71mysql.t, manually using NoBindVars. This is to give that code
5# wider testing, since virtually nobody who regularly runs the test suite
6# is using DBD::Sybase+FreeTDS+MSSQL -- blblack
7
8use Test::More;
9use lib qw(t/lib);
10use DBICTest;
11use DBI::Const::GetInfoType;
12
13my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_MYSQL_${_}" } qw/DSN USER PASS/};
14
15#warn "$dsn $user $pass";
16
17plan skip_all => 'Set $ENV{DBICTEST_MYSQL_DSN}, _USER and _PASS to run this test'
18 unless ($dsn && $user);
19
20plan tests => 4;
21
22{ # Fake storage driver for mysql + no bind variables
23 package DBIx::Class::Storage::DBI::MySQLNoBindVars;
24 use base qw/
25 DBIx::Class::Storage::DBI::mysql
26 DBIx::Class::Storage::DBI::NoBindVars
27 /;
28 $INC{'DBIx/Class/Storage/DBI/MySQLNoBindVars.pm'} = 1;
29}
30
3ff5b740 31my $schema = DBICTest::Schema->clone;
32$schema->storage_type('::DBI::MySQLNoBindVars');
33$schema->connection($dsn, $user, $pass);
d5130dd2 34
3ff5b740 35my $dbh = $schema->storage->dbh;
d5130dd2 36
37$dbh->do("DROP TABLE IF EXISTS artist;");
38
39$dbh->do("CREATE TABLE artist (artistid INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, name VARCHAR(255), charfield CHAR(10));");
40
3ff5b740 41$schema->class('Artist')->load_components('PK::Auto');
d5130dd2 42
43# test primary key handling
3ff5b740 44my $new = $schema->resultset('Artist')->create({ name => 'foo' });
d5130dd2 45ok($new->artistid, "Auto-PK worked");
46
47# test LIMIT support
48for (1..6) {
3ff5b740 49 $schema->resultset('Artist')->create({ name => 'Artist ' . $_ });
d5130dd2 50}
3ff5b740 51my $it = $schema->resultset('Artist')->search( {},
d5130dd2 52 { rows => 3,
53 offset => 2,
54 order_by => 'artistid' }
55);
56is( $it->count, 3, "LIMIT count ok" );
57is( $it->next->name, "Artist 2", "iterator->next ok" );
58$it->next;
59$it->next;
60is( $it->next, undef, "next past end of resultset ok" );
61
62# clean up our mess
3ff5b740 63END {
64 $dbh->do("DROP TABLE artist");
65}