bump CAG dep
[dbsrgits/DBIx-Class.git] / t / prefetch / double_prefetch.t
CommitLineData
f1952f5c 1use warnings;
2
3use Test::More;
4use Test::Exception;
5use lib qw(t/lib);
6use DBIC::SqlMakerTest;
7use DBICTest;
8
9my $schema = DBICTest->init_schema();
10
11plan 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
15my $cds = $schema->resultset('Artist')
16 ->search_related ('cds')
17 ->search ({}, {
18 prefetch => [ 'single_track', { single_track => 'cd' } ],
19 });
20
21is_same_sql(
22 ${$cds->as_query}->[0],
23 '(
24 SELECT
25 cds.cdid, cds.artist, cds.title, cds.year, cds.genreid, cds.single_track,
e6d62860 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,
f1952f5c 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);