Modify the null-branch pruning introduced in ce556881, restore compat
[dbsrgits/DBIx-Class.git] / t / prefetch / false_colvalues.t
CommitLineData
f4e13e13 1use warnings;
2use strict;
3
4use Test::More;
52864fbd 5use Test::Deep;
f4e13e13 6
7use lib qw(t/lib);
8use DBICTest;
9
10my $schema = DBICTest->init_schema(
11 no_populate => 1,
12);
13
14$schema->resultset('CD')->create({
15 cdid => 0,
16 artist => {
17 artistid => 0,
18 name => '',
19 rank => 0,
20 charfield => 0,
21 },
22 title => '',
23 year => 0,
24 genreid => 0,
25 single_track => 0,
26});
27
28my $orig_debug = $schema->storage->debug;
29
30my $queries = 0;
31$schema->storage->debugcb(sub { $queries++; });
32$schema->storage->debug(1);
33
34my $cd = $schema->resultset('CD')->search( {}, { prefetch => 'artist' })->next;
35
52864fbd 36cmp_deeply
f4e13e13 37 { $cd->get_columns },
38 {
39 artist => 0,
40 cdid => 0,
41 genreid => 0,
42 single_track => 0,
43 title => '',
44 year => 0,
45 },
46 'Expected CD columns present',
47;
48
52864fbd 49cmp_deeply
f4e13e13 50 { $cd->artist->get_columns },
51 {
52 artistid => 0,
53 charfield => 0,
54 name => "",
55 rank => 0,
56 },
57 'Expected Artist columns present',
58;
59
60is $queries, 1, 'Only one query fired - prefetch worked';
61
62$schema->storage->debugcb(undef);
63$schema->storage->debug($orig_debug);
64
65done_testing;