Clarify and disable rows/prefetch test - fix is easy, but architecturally unsound...
[dbsrgits/DBIx-Class.git] / t / prefetch / rows_bug.t
CommitLineData
a04af85f 1# Test to ensure we get a consistent result set wether or not we use the
2# prefetch option in combination rows (LIMIT).
3use strict;
4use warnings;
5
6use Test::More;
7use lib qw(t/lib);
8use DBICTest;
9
9117ccfb 10plan skip_all => 'fix pending';
11#plan tests => 4;
a04af85f 12
13my $schema = DBICTest->init_schema();
14my $no_prefetch = $schema->resultset('Artist')->search(
25cac750 15 undef,
16 { rows => 3 }
a04af85f 17);
18
19my $use_prefetch = $schema->resultset('Artist')->search(
25cac750 20 undef,
21 {
22 prefetch => 'cds',
23 rows => 3
24 }
a04af85f 25);
26
a04af85f 27is($no_prefetch->count, $use_prefetch->count, '$no_prefetch->count == $use_prefetch->count');
5624ba1f 28is(
9117ccfb 29 scalar ($no_prefetch->all),
30 scalar ($use_prefetch->all),
31 "Amount of returned rows is right"
5624ba1f 32);
33
9117ccfb 34
35
36my $artist_many_cds = $schema->resultset('Artist')->search ( {}, {
37 join => 'cds',
38 group_by => 'me.artistid',
39 having => \ 'count(cds.cdid) > 1',
40})->first;
41
42
5624ba1f 43$no_prefetch = $schema->resultset('Artist')->search(
9117ccfb 44 { artistid => $artist_many_cds->id },
5624ba1f 45 { rows => 1 }
46);
47
48$use_prefetch = $schema->resultset('Artist')->search(
9117ccfb 49 { artistid => $artist_many_cds->id },
5624ba1f 50 {
51 prefetch => 'cds',
52 rows => 1
53 }
54);
55
56my $prefetch_artist = $use_prefetch->first;
57my $normal_artist = $no_prefetch->first;
58
59is(
60 $prefetch_artist->cds->count,
61 $normal_artist->cds->count,
62 "Count of child rel with prefetch + rows => 1 is right"
63);
9117ccfb 64is (
65 scalar ($prefetch_artist->cds->all),
66 scalar ($normal_artist->cds->all),
67 "Amount of child rel rows with prefetch + rows => 1 is right"
68);