File: 86might_have.t

package info (click to toggle)
libdbix-class-perl 0.08010-2
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 2,052 kB
  • ctags: 1,064
  • sloc: perl: 10,536; sql: 225; makefile: 45
file content (47 lines) | stat: -rwxr-xr-x 905 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
use strict;
use warnings;  

use Test::More;
use lib qw(t/lib);
use DBICTest;

my $schema = DBICTest->init_schema();

my $queries;
#$schema->storage->debugfh(IO::File->new('t/var/temp.trace', 'w'));
$schema->storage->debugcb( sub{ $queries++ } );

eval "use DBD::SQLite";
plan skip_all => 'needs DBD::SQLite for testing' if $@;
plan tests => 2;


my $cd = $schema->resultset("CD")->find(1);
$cd->title('test');

# SELECT count
$queries = 0;
$schema->storage->debug(1);

$cd->update;

is($queries, 1, 'liner_notes (might_have) not prefetched - do not load 
liner_notes on update');

$schema->storage->debug(0);


my $cd2 = $schema->resultset("CD")->find(2, {prefetch => 'liner_notes'});
$cd2->title('test2');

# SELECT count
$queries = 0;
$schema->storage->debug(1);

$cd2->update;

is($queries, 1, 'liner_notes (might_have) prefetched - do not load 
liner_notes on update');

$schema->storage->debug(0);