Commit | Line | Data |
b6b8f72f |
1 | use strict; |
2 | use warnings; |
3 | |
4 | use Test::More; |
5 | |
6 | use lib qw(t/lib); |
7 | use DBICTest; |
8 | |
9 | my $schema = DBICTest->init_schema(); |
10 | |
1016d167 |
11 | my $queries; |
12 | my $debugcb = sub { $queries++; }; |
13 | my $orig_debug = $schema->storage->debug; |
14 | |
15 | { |
16 | $queries = 0; |
17 | $schema->storage->debugcb($debugcb); |
18 | $schema->storage->debug(1); |
19 | |
20 | my $cds_rs = $schema->resultset('CD') |
21 | ->search(\'0 = 1', { prefetch => 'tracks', cache => 1 }); |
22 | |
23 | my @cds = $cds_rs->all; |
24 | is( $queries, 1, '->all on empty original resultset hit db' ); |
25 | is_deeply( $cds_rs->get_cache, [], 'empty cache on original resultset' ); |
26 | is( 0+@cds, 0, 'empty original resultset' ); |
b6b8f72f |
27 | |
1016d167 |
28 | my $tracks_rs = $cds_rs->related_resultset('tracks'); |
29 | is_deeply( $tracks_rs->get_cache, [], 'empty cache on related resultset' ); |
30 | |
31 | my @tracks = $tracks_rs->all; |
32 | is( $queries, 1, "->all on empty related resultset didn't hit db" ); |
33 | is( 0+@tracks, 0, 'empty related resultset' ); |
34 | |
35 | $schema->storage->debugcb(undef); |
36 | $schema->storage->debug($orig_debug); |
37 | } |
b6b8f72f |
38 | |
39 | done_testing; |