Make sure IO::Handle is loaded - missing stubs on older perls
[dbsrgits/DBIx-Class.git] / t / storage / nobindvars.t
CommitLineData
d5130dd2 1use strict;
68de9438 2use warnings;
d5130dd2 3
4use Test::More;
5use lib qw(t/lib);
6use DBICTest;
d5130dd2 7
6e6ad6c3 8{ # Fake storage driver for SQLite + no bind variables
9 package DBICTest::SQLite::NoBindVars;
2cfc22dd 10 use base qw(
11 DBIx::Class::Storage::DBI::NoBindVars
12 DBIx::Class::Storage::DBI::SQLite
13 );
14 use mro 'c3';
d5130dd2 15}
16
6e6ad6c3 17my $schema = DBICTest->init_schema (storage_type => 'DBICTest::SQLite::NoBindVars', no_populate => 1);
d5130dd2 18
19# test primary key handling
3ff5b740 20my $new = $schema->resultset('Artist')->create({ name => 'foo' });
d5130dd2 21ok($new->artistid, "Auto-PK worked");
22
23# test LIMIT support
24for (1..6) {
3ff5b740 25 $schema->resultset('Artist')->create({ name => 'Artist ' . $_ });
d5130dd2 26}
3ff5b740 27my $it = $schema->resultset('Artist')->search( {},
d5130dd2 28 { rows => 3,
29 offset => 2,
30 order_by => 'artistid' }
31);
6e6ad6c3 32
fb4b58e8 33is( $it->count, 3, "LIMIT count ok" ); # ask for 3 rows out of 7 artists
6e6ad6c3 34
2cfc22dd 35$schema->is_executed_sql_bind( sub {
36 is( $it->next->name, "Artist 2", "iterator->next ok" );
37 $it->next;
38 $it->next;
39 is( $it->next, undef, "next past end of resultset ok" );
40}, [
41 [ 'SELECT me.artistid, me.name, me.rank, me.charfield FROM artist me ORDER BY artistid LIMIT 3 OFFSET 2' ],
42], 'Correctly interpolated SQL' );
68de9438 43
44done_testing;