Adding datetime_undef_if_invalid to squelch errors on DateTime inflation of bogus...
[dbsrgits/DBIx-Class.git] / t / 86might_have.t
CommitLineData
70350518 1use strict;
2use warnings;
3
4use Test::More;
5use lib qw(t/lib);
6use DBICTest;
7
a47e1233 8my $schema = DBICTest->init_schema();
8417f5ee 9
10my $queries;
11#$schema->storage->debugfh(IO::File->new('t/var/temp.trace', 'w'));
12$schema->storage->debugcb( sub{ $queries++ } );
13
14eval "use DBD::SQLite";
15plan skip_all => 'needs DBD::SQLite for testing' if $@;
16plan tests => 2;
17
18
19my $cd = $schema->resultset("CD")->find(1);
20$cd->title('test');
21
22# SELECT count
23$queries = 0;
24$schema->storage->debug(1);
25
26$cd->update;
27
28is($queries, 1, 'liner_notes (might_have) not prefetched - do not load
29liner_notes on update');
30
31$schema->storage->debug(0);
32
33
34my $cd2 = $schema->resultset("CD")->find(2, {prefetch => 'liner_notes'});
50f18b6b 35$cd2->title('test2');
8417f5ee 36
37# SELECT count
38$queries = 0;
39$schema->storage->debug(1);
40
41$cd2->update;
42
43is($queries, 1, 'liner_notes (might_have) prefetched - do not load
44liner_notes on update');
45
46$schema->storage->debug(0);
8417f5ee 47