Commit | Line | Data |
d5130dd2 |
1 | use strict; |
2 | use 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 | |
8 | use Test::More; |
9 | use lib qw(t/lib); |
10 | use DBICTest; |
11 | use DBI::Const::GetInfoType; |
12 | |
13 | my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_MYSQL_${_}" } qw/DSN USER PASS/}; |
14 | |
15 | #warn "$dsn $user $pass"; |
16 | |
17 | plan skip_all => 'Set $ENV{DBICTEST_MYSQL_DSN}, _USER and _PASS to run this test' |
18 | unless ($dsn && $user); |
19 | |
20 | plan tests => 4; |
21 | |
22 | { # Fake storage driver for mysql + no bind variables |
23 | package DBIx::Class::Storage::DBI::MySQLNoBindVars; |
d944c5ae |
24 | use Class::C3; |
d5130dd2 |
25 | use base qw/ |
d5130dd2 |
26 | DBIx::Class::Storage::DBI::NoBindVars |
d944c5ae |
27 | DBIx::Class::Storage::DBI::mysql |
d5130dd2 |
28 | /; |
29 | $INC{'DBIx/Class/Storage/DBI/MySQLNoBindVars.pm'} = 1; |
30 | } |
31 | |
d944c5ae |
32 | # XXX Class::C3 doesn't like some of the Storage stuff happening late... |
33 | Class::C3::reinitialize(); |
34 | |
3ff5b740 |
35 | my $schema = DBICTest::Schema->clone; |
36 | $schema->storage_type('::DBI::MySQLNoBindVars'); |
37 | $schema->connection($dsn, $user, $pass); |
d5130dd2 |
38 | |
3ff5b740 |
39 | my $dbh = $schema->storage->dbh; |
d5130dd2 |
40 | |
41 | $dbh->do("DROP TABLE IF EXISTS artist;"); |
42 | |
a0dd8679 |
43 | $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));"); |
d5130dd2 |
44 | |
3ff5b740 |
45 | $schema->class('Artist')->load_components('PK::Auto'); |
d5130dd2 |
46 | |
47 | # test primary key handling |
3ff5b740 |
48 | my $new = $schema->resultset('Artist')->create({ name => 'foo' }); |
d5130dd2 |
49 | ok($new->artistid, "Auto-PK worked"); |
50 | |
51 | # test LIMIT support |
52 | for (1..6) { |
3ff5b740 |
53 | $schema->resultset('Artist')->create({ name => 'Artist ' . $_ }); |
d5130dd2 |
54 | } |
3ff5b740 |
55 | my $it = $schema->resultset('Artist')->search( {}, |
d5130dd2 |
56 | { rows => 3, |
57 | offset => 2, |
58 | order_by => 'artistid' } |
59 | ); |
fb4b58e8 |
60 | is( $it->count, 3, "LIMIT count ok" ); # ask for 3 rows out of 7 artists |
d5130dd2 |
61 | is( $it->next->name, "Artist 2", "iterator->next ok" ); |
62 | $it->next; |
63 | $it->next; |
64 | is( $it->next, undef, "next past end of resultset ok" ); |
65 | |
66 | # clean up our mess |
3ff5b740 |
67 | END { |
3a4c1d89 |
68 | my $dbh = eval { $schema->storage->_dbh }; |
cd99a557 |
69 | $dbh->do("DROP TABLE artist") if $dbh; |
3ff5b740 |
70 | } |