8 use DBIC::SqlMakerTest;
13 my $schema = DBICTest->init_schema();
15 # non-collapsing prefetch (no multi prefetches)
17 my $rs = $schema->resultset("CD")
18 ->search_related('tracks',
19 { position => [1,2] },
20 { prefetch => [qw/disc lyrics/], rows => 3, offset => 8 },
22 is ($rs->all, 2, 'Correct number of objects');
26 $schema->storage->debugobj(DBIC::DebugObj->new(\$sql, \@bind));
27 $schema->storage->debug(1);
29 is ($rs->count, 2, 'Correct count via count()');
36 JOIN track tracks ON tracks.cd = me.cdid
37 JOIN cd disc ON disc.cdid = tracks.cd
38 LEFT JOIN lyrics lyrics ON lyrics.track_id = tracks.trackid
39 WHERE ( ( position = ? OR position = ? ) )
42 'count softlimit applied',
45 my $crs = $rs->count_rs;
46 is ($crs->next, 2, 'Correct count via count_rs()');
54 JOIN track tracks ON tracks.cd = me.cdid
55 JOIN cd disc ON disc.cdid = tracks.cd
56 LEFT JOIN lyrics lyrics ON lyrics.track_id = tracks.trackid
57 WHERE ( ( position = ? OR position = ? ) )
61 [ [ position => 1 ], [ position => 2 ] ],
62 'count_rs db-side limit applied',
66 # has_many prefetch with limit
68 my $rs = $schema->resultset("Artist")
69 ->search_related('cds',
70 { 'tracks.position' => [1,2] },
71 { prefetch => [qw/tracks artist/], rows => 3, offset => 4 },
73 is ($rs->all, 1, 'Correct number of objects');
76 $schema->storage->debugobj(DBIC::DebugObj->new(\$sql, \@bind));
77 $schema->storage->debug(1);
79 is ($rs->count, 1, 'Correct count via count()');
88 JOIN cd cds ON cds.artist = me.artistid
89 LEFT JOIN track tracks ON tracks.cd = cds.cdid
90 JOIN artist artist ON artist.artistid = cds.artist
91 WHERE tracks.position = ? OR tracks.position = ?
96 'count softlimit applied',
99 my $crs = $rs->count_rs;
100 is ($crs->next, 1, 'Correct count via count_rs()');
108 JOIN cd cds ON cds.artist = me.artistid
109 LEFT JOIN track tracks ON tracks.cd = cds.cdid
110 JOIN artist artist ON artist.artistid = cds.artist
111 WHERE tracks.position = ? OR tracks.position = ?
116 [ [ 'tracks.position' => 1 ], [ 'tracks.position' => 2 ] ],
117 'count_rs db-side limit applied',