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