1 # Test to ensure we get a consistent result set wether or not we use the
2 # prefetch option in combination rows (LIMIT).
12 my $schema = DBICTest->init_schema();
15 my $no_prefetch = $schema->resultset('Artist')->search(
20 my $use_prefetch = $schema->resultset('Artist')->search(
21 [ # search deliberately contrived
22 { 'artwork.cd_id' => undef },
23 { 'tracks.title' => { '!=' => 'blah-blah-1234568' }}
27 join => { cds => [qw/artwork tracks/] },
29 order_by => { -desc => 'name' },
33 is($no_prefetch->count, $use_prefetch->count, '$no_prefetch->count == $use_prefetch->count');
35 scalar ($no_prefetch->all),
36 scalar ($use_prefetch->all),
37 "Amount of returned rows is right"
40 my $artist_many_cds = $schema->resultset('Artist')->search ( {}, {
42 group_by => 'me.artistid',
43 having => \ 'count(cds.cdid) > 1',
47 $no_prefetch = $schema->resultset('Artist')->search(
48 { artistid => $artist_many_cds->id },
52 $use_prefetch = $schema->resultset('Artist')->search(
53 { artistid => $artist_many_cds->id },
60 my $prefetch_artist = $use_prefetch->first;
61 my $normal_artist = $no_prefetch->first;
64 $prefetch_artist->cds->count,
65 $normal_artist->cds->count,
66 "Count of child rel with prefetch + rows => 1 is right"
69 scalar ($prefetch_artist->cds->all),
70 scalar ($normal_artist->cds->all),
71 "Amount of child rel rows with prefetch + rows => 1 is right"