Commit | Line | Data |
a04af85f |
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 | |
9117ccfb |
10 | plan skip_all => 'fix pending'; |
11 | #plan tests => 4; |
a04af85f |
12 | |
13 | my $schema = DBICTest->init_schema(); |
14 | my $no_prefetch = $schema->resultset('Artist')->search( |
25cac750 |
15 | undef, |
16 | { rows => 3 } |
a04af85f |
17 | ); |
18 | |
19 | my $use_prefetch = $schema->resultset('Artist')->search( |
25cac750 |
20 | undef, |
21 | { |
22 | prefetch => 'cds', |
23 | rows => 3 |
24 | } |
a04af85f |
25 | ); |
26 | |
a04af85f |
27 | is($no_prefetch->count, $use_prefetch->count, '$no_prefetch->count == $use_prefetch->count'); |
5624ba1f |
28 | is( |
9117ccfb |
29 | scalar ($no_prefetch->all), |
30 | scalar ($use_prefetch->all), |
31 | "Amount of returned rows is right" |
5624ba1f |
32 | ); |
33 | |
9117ccfb |
34 | |
35 | |
36 | my $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 | |
56 | my $prefetch_artist = $use_prefetch->first; |
57 | my $normal_artist = $no_prefetch->first; |
58 | |
59 | is( |
60 | $prefetch_artist->cds->count, |
61 | $normal_artist->cds->count, |
62 | "Count of child rel with prefetch + rows => 1 is right" |
63 | ); |
9117ccfb |
64 | is ( |
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 | ); |