bump CAG dep
[dbsrgits/DBIx-Class.git] / t / prefetch / double_prefetch.t
1 use warnings;  
2
3 use Test::More;
4 use Test::Exception;
5 use lib qw(t/lib);
6 use DBIC::SqlMakerTest;
7 use DBICTest;
8
9 my $schema = DBICTest->init_schema();
10
11 plan tests => 1;
12
13 # While this is a rather GIGO case, make sure it behaves as pre-103,
14 # as it may result in hard-to-track bugs
15 my $cds = $schema->resultset('Artist')
16             ->search_related ('cds')
17               ->search ({}, {
18                   prefetch => [ 'single_track', { single_track => 'cd' } ],
19                 });
20
21 is_same_sql(
22   ${$cds->as_query}->[0],
23   '(
24     SELECT
25       cds.cdid, cds.artist, cds.title, cds.year, cds.genreid, cds.single_track,
26       single_track.trackid, single_track.cd, single_track.position, single_track.title, single_track.last_updated_on, single_track.last_updated_at, single_track.small_dt,
27       single_track_2.trackid, single_track_2.cd, single_track_2.position, single_track_2.title, single_track_2.last_updated_on, single_track_2.last_updated_at, single_track_2.small_dt,
28       cd.cdid, cd.artist, cd.title, cd.year, cd.genreid, cd.single_track
29     FROM artist me
30       LEFT JOIN cd cds ON cds.artist = me.artistid
31       LEFT JOIN track single_track ON single_track.trackid = cds.single_track
32       LEFT JOIN track single_track_2 ON single_track_2.trackid = cds.single_track
33       LEFT JOIN cd cd ON cd.cdid = single_track_2.cd
34   )',
35 );