Some testdb changes and alignment, preparing for test refactor branch
[dbsrgits/DBIx-Class.git] / t / 98rows_prefetch.t
1 # Test to ensure we get a consistent result set wether or not we use the
2 # prefetch option in combination rows (LIMIT).
3 use strict;
4 use warnings;
5
6 use Test::More;
7 use lib qw(t/lib);
8 use DBICTest;
9
10 plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 2);
11
12 my $schema = DBICTest->init_schema();
13 my $no_prefetch = $schema->resultset('Artist')->search(
14         undef,
15         { rows => 3 }
16 );
17
18 my $use_prefetch = $schema->resultset('Artist')->search(
19         undef,
20         {
21                 prefetch => 'cds',
22                 rows     => 3
23         }
24 );
25
26 my $no_prefetch_count  = 0;
27 my $use_prefetch_count = 0;
28
29 is($no_prefetch->count, $use_prefetch->count, '$no_prefetch->count == $use_prefetch->count');
30
31 TODO: {
32         local $TODO = "This is a difficult bug to fix, workaround is not to use prefetch with rows";
33         $no_prefetch_count++  while $no_prefetch->next;
34         $use_prefetch_count++ while $use_prefetch->next;
35         is(
36                 $no_prefetch_count,
37                 $use_prefetch_count,
38                 "manual row count confirms consistency"
39                 . " (\$no_prefetch_count == $no_prefetch_count, "
40                 . " \$use_prefetch_count == $use_prefetch_count)"
41         );
42 }