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 WHERE ( ( position = ? OR position = ? ) )
41 'count softlimit applied',
44 my $crs = $rs->count_rs;
45 is ($crs->next, 2, 'Correct count via count_rs()');
53 JOIN track tracks ON tracks.cd = me.cdid
54 JOIN cd disc ON disc.cdid = tracks.cd
55 WHERE ( ( position = ? OR position = ? ) )
59 [ [ position => 1 ], [ position => 2 ] ],
60 'count_rs db-side limit applied',
64 # has_many prefetch with limit
66 my $rs = $schema->resultset("Artist")
67 ->search_related('cds',
68 { 'tracks.position' => [1,2] },
69 { prefetch => [qw/tracks artist/], rows => 3, offset => 4 },
71 is ($rs->all, 1, 'Correct number of objects');
74 $schema->storage->debugobj(DBIC::DebugObj->new(\$sql, \@bind));
75 $schema->storage->debug(1);
77 is ($rs->count, 1, 'Correct count via count()');
86 JOIN cd cds ON cds.artist = me.artistid
87 LEFT JOIN track tracks ON tracks.cd = cds.cdid
88 JOIN artist artist ON artist.artistid = cds.artist
89 WHERE tracks.position = ? OR tracks.position = ?
94 'count softlimit applied',
97 my $crs = $rs->count_rs;
98 is ($crs->next, 1, 'Correct count via count_rs()');
106 JOIN cd cds ON cds.artist = me.artistid
107 LEFT JOIN track tracks ON tracks.cd = cds.cdid
108 JOIN artist artist ON artist.artistid = cds.artist
109 WHERE tracks.position = ? OR tracks.position = ?
114 [ [ 'tracks.position' => 1 ], [ 'tracks.position' => 2 ] ],
115 'count_rs db-side limit applied',