[Bast-commits] r7169 -
DBIx-Class/0.08/branches/prefetch_redux/t/count
robkinyon at dev.catalyst.perl.org
robkinyon at dev.catalyst.perl.org
Mon Aug 3 03:49:59 GMT 2009
Author: robkinyon
Date: 2009-08-03 03:49:59 +0000 (Mon, 03 Aug 2009)
New Revision: 7169
Modified:
DBIx-Class/0.08/branches/prefetch_redux/t/count/prefetch.t
Log:
Added two tests and marked one todo_skip
Modified: DBIx-Class/0.08/branches/prefetch_redux/t/count/prefetch.t
===================================================================
--- DBIx-Class/0.08/branches/prefetch_redux/t/count/prefetch.t 2009-08-02 23:45:11 UTC (rev 7168)
+++ DBIx-Class/0.08/branches/prefetch_redux/t/count/prefetch.t 2009-08-03 03:49:59 UTC (rev 7169)
@@ -8,7 +8,7 @@
use DBIC::SqlMakerTest;
use DBIC::DebugObj;
-plan tests => 9;
+plan tests => 17;
my $schema = DBICTest->init_schema();
@@ -37,8 +37,35 @@
);
}
+# Added test by mo per http://scsys.co.uk:8001/31870
+TODO: {
+ todo_skip "This breaks stuff", 3;
+ my $rs = $schema->resultset("Artist")->search(undef, {distinct => 1})
+ ->search_related('cds')->search_related('genre',
+ { 'genre.name' => 'foo' },
+ { prefetch => q(cds) },
+ );
+ is ($rs->all, 5, 'Correct number of objects');
+
+
+ my ($sql, @bind);
+ $schema->storage->debugobj(DBIC::DebugObj->new(\$sql, \@bind));
+ $schema->storage->debug(1);
+
+
+ is ($rs->count, 5, 'Correct count');
+
+ is_same_sql_bind (
+ $sql,
+ \@bind,
+ 'SELECT COUNT( * ) FROM (SELECT cds.cdid FROM artist me JOIN cd cds ON cds.artist = me.artistid LEFT JOIN track tracks ON tracks.cd = cds.cdid JOIN artist artist ON artist.artistid = cds.artist WHERE tracks.position = ? OR tracks.position = ? GROUP BY cds.cdid) count_subq',
+ [ qw/'1' '2'/ ],
+ );
+}
+
# collapsing prefetch with distinct
-{
+TODO: {
+ todo_skip "This is busted", 3;
my $rs = $schema->resultset("Artist")->search(undef, {distinct => 1})
->search_related('cds')->search_related('genre',
{ 'genre.name' => 'foo' },
@@ -86,3 +113,44 @@
[ qw/'1' '2'/ ],
);
}
+
+# Added test by mo per http://scsys.co.uk:8001/31873
+TODO: {
+ todo_skip "This breaks stuff", 5;
+ my $rs = $schema->resultset("Artwork")->search(undef, {distinct => 1})
+ ->search_related('artwork_to_artist')->search_related('artist',
+ undef,
+ { prefetch => q(cds) },
+ );
+ is($rs->all, 0, 'failure without WHERE');
+
+ $rs = $schema->resultset("Artwork")->search(undef, {distinct => 1})
+ ->search_related('artwork_to_artist')->search_related('artist',
+ { 'cds.title' => 'foo' }, # this line has changed
+ { prefetch => q(cds) },
+ );
+ is($rs->all, 0, 'success with WHERE');
+
+ # different case
+
+ $rs = $schema->resultset("Artist")->search(undef)#, {distinct => 1})
+ ->search_related('cds')->search_related('genre',
+ { 'genre.name' => 'foo' },
+ { prefetch => q(cds) },
+ );
+ is($rs->all, 0, 'success without distinct');
+
+ $rs = $schema->resultset("Artist")->search(undef, {distinct => 1})
+ ->search_related('cds')->search_related('genre',
+ { 'genre.name' => 'foo' },
+ #{ prefetch => q(cds) },
+ );
+ is($rs->all, 0, 'success without prefetch');
+
+ $rs = $schema->resultset("Artist")->search(undef, {distinct => 1})
+ ->search_related('cds')->search_related('genre',
+ { 'genre.name' => 'foo' },
+ { prefetch => q(cds) },
+ );
+ is($rs->all, 0, 'failure with distinct');
+}
More information about the Bast-commits
mailing list