failing test
[dbsrgits/DBIx-Class.git] / t / prefetch / unresolvable.t
1 use strict;
2 use warnings;  
3
4 use Test::More;
5 use Test::Exception;
6 use lib qw(t/lib);
7 use DBICTest;
8
9 my $schema = DBICTest->init_schema();
10
11 eval "use DBD::SQLite";
12 plan skip_all => 'needs DBD::SQLite for testing' if $@;
13 plan tests => 1;
14
15 =cut
16 test fails with select => [ ], when the columns required for the relationship are absent
17
18 DBIC_TRACE=1:
19
20   with select => [ qw / me.name cds.title ] (missing columns required for relationships)
21
22   SELECT me.name, cds.title, cds.cdid, cds.artist, cds.title, cds.year, cds.genreid, cds.single_track
23   FROM artist me
24   LEFT JOIN cd cds ON cds.artist = me.artistid
25   WHERE ( cds.title != ? )
26   GROUP BY me.name, cds.title
27   ORDER BY me.name, cds.title, cds.artist, cds.year: 'Generic Manufactured Singles'
28
29   ****************************************************************************************************************************
30
31   with no select => [ ]
32
33   SELECT me.artistid, me.name, me.rank, me.charfield, cds.cdid, cds.artist, cds.title, cds.year, cds.genreid, cds.single_track
34   FROM artist me
35   LEFT JOIN cd cds ON cds.artist = me.artistid 
36   WHERE ( cds.title != ? )
37   GROUP BY me.artistid, me.name, me.rank, me.charfield
38   ORDER BY me.name, cds.title, cds.artist, cds.year: 'Generic Manufactured Singles'
39
40 =cut
41
42
43 my $rs = $schema->resultset('Artist')->search({ 'cds.title' => { '!=' => 'Generic Manufactured Singles' } }, ## exists
44                                               { prefetch => [ qw/ cds / ],
45                                                 join => [ qw/ cds / ],
46                                                 select => [ qw/ me.name cds.title / ],
47                                                 distinct => 1,
48                                                 order_by => [ qw/ me.name cds.title / ],
49                                               });
50
51 lives_ok(sub { $rs->first }, 'Lives ok');