04db test now uses txn_* API rather than storage->dbh hacks
[dbsrgits/DBIx-Class.git] / t / run / 15limit.tl
CommitLineData
0567538f 1sub run_tests {
2
3BEGIN {
4 eval "use DBD::SQLite";
5 plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 9);
6}
7
8# test LIMIT
9my $it = DBICTest::CD->search( {},
10 { rows => 3,
11 order_by => 'title' }
12);
13is( $it->count, 3, "count ok" );
14is( $it->next->title, "Caterwaulin' Blues", "iterator->next ok" );
15$it->next;
16$it->next;
17is( $it->next, undef, "next past end of resultset ok" );
18
19# test OFFSET
20my @cds = DBICTest::CD->search( {},
21 { rows => 2,
22 offset => 2,
23 order_by => 'year' }
24);
25is( $cds[0]->title, "Spoonful of bees", "offset ok" );
26
27# test software-based limiting
28$it = DBICTest::CD->search( {},
29 { rows => 3,
30 software_limit => 1,
31 order_by => 'title' }
32);
33is( $it->count, 3, "software limit count ok" );
34is( $it->next->title, "Caterwaulin' Blues", "software iterator->next ok" );
35$it->next;
36$it->next;
37is( $it->next, undef, "software next past end of resultset ok" );
38
39@cds = DBICTest::CD->search( {},
40 { rows => 2,
41 offset => 2,
42 software_limit => 1,
43 order_by => 'year' }
44);
45is( $cds[0]->title, "Spoonful of bees", "software offset ok" );
46
47# based on a failing criteria submitted by waswas
48# requires SQL::Abstract >= 1.20
49$it = DBICTest::CD->search(
50 { title => [
51 -and =>
52 {
53 -like => '%bees'
54 },
55 {
56 -not_like => 'Forkful%'
57 }
58 ]
59 },
60 { rows => 5 }
61);
62is( $it->count, 1, "complex abstract count ok" );
63
64}
65
661;