Commit | Line | Data |
8417f5ee |
1 | sub run_tests { |
2 | my $schema = shift; |
3 | |
4 | my $queries; |
5 | #$schema->storage->debugfh(IO::File->new('t/var/temp.trace', 'w')); |
6 | $schema->storage->debugcb( sub{ $queries++ } ); |
7 | |
8 | eval "use DBD::SQLite"; |
9 | plan skip_all => 'needs DBD::SQLite for testing' if $@; |
10 | plan tests => 2; |
11 | |
12 | |
13 | my $cd = $schema->resultset("CD")->find(1); |
14 | $cd->title('test'); |
15 | |
16 | # SELECT count |
17 | $queries = 0; |
18 | $schema->storage->debug(1); |
19 | |
20 | $cd->update; |
21 | |
22 | is($queries, 1, 'liner_notes (might_have) not prefetched - do not load |
23 | liner_notes on update'); |
24 | |
25 | $schema->storage->debug(0); |
26 | |
27 | |
28 | my $cd2 = $schema->resultset("CD")->find(2, {prefetch => 'liner_notes'}); |
50f18b6b |
29 | $cd2->title('test2'); |
8417f5ee |
30 | |
31 | # SELECT count |
32 | $queries = 0; |
33 | $schema->storage->debug(1); |
34 | |
35 | $cd2->update; |
36 | |
37 | is($queries, 1, 'liner_notes (might_have) prefetched - do not load |
38 | liner_notes on update'); |
39 | |
40 | $schema->storage->debug(0); |
41 | } |
42 | |
43 | 1; |