minor fix to last committed test
[dbsrgits/DBIx-Class.git] / t / 86might_have.t
1 use strict;
2 use warnings;  
3
4 use Test::More;
5 use lib qw(t/lib);
6 use DBICTest;
7
8 my $schema = DBICTest->init_schema();
9
10 my $queries;
11 $schema->storage->debugcb( sub{ $queries++ } );
12 my $sdebug = $schema->storage->debug;
13
14 plan tests => 2;
15
16 my $cd = $schema->resultset("CD")->find(1);
17 $cd->title('test');
18
19 # SELECT count
20 $queries = 0;
21 $schema->storage->debug(1);
22
23 $cd->update;
24
25 is($queries, 1, 'liner_notes (might_have) not prefetched - do not load 
26 liner_notes on update');
27
28 $schema->storage->debug($sdebug);
29
30
31 my $cd2 = $schema->resultset("CD")->find(2, {prefetch => 'liner_notes'});
32 $cd2->title('test2');
33
34 # SELECT count
35 $queries = 0;
36 $schema->storage->debug(1);
37
38 $cd2->update;
39
40 is($queries, 1, 'liner_notes (might_have) prefetched - do not load 
41 liner_notes on update');
42
43 $schema->storage->debug($sdebug);