failing test
[dbsrgits/DBIx-Class.git] / t / prefetch / unresolvable.t
CommitLineData
5aa25b93 1use strict;
2use warnings;
3
4use Test::More;
5use Test::Exception;
6use lib qw(t/lib);
7use DBICTest;
8
9my $schema = DBICTest->init_schema();
10
11eval "use DBD::SQLite";
12plan skip_all => 'needs DBD::SQLite for testing' if $@;
13plan tests => 1;
14
15=cut
16test fails with select => [ ], when the columns required for the relationship are absent
17
18DBIC_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
43my $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
51lives_ok(sub { $rs->first }, 'Lives ok');