From: David Kamholz Date: Thu, 23 Feb 2006 11:09:00 +0000 (+0000) Subject: attempt to fix weird overload '0+' bug, modify tests to make sure it works X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ebaefbc2d27ee15e14f8d509346658376925f152;p=dbsrgits%2FDBIx-Class-Historic.git attempt to fix weird overload '0+' bug, modify tests to make sure it works --- diff --git a/lib/DBIx/Class/ResultSet.pm b/lib/DBIx/Class/ResultSet.pm index ab96fff..5d6f601 100644 --- a/lib/DBIx/Class/ResultSet.pm +++ b/lib/DBIx/Class/ResultSet.pm @@ -3,7 +3,7 @@ package DBIx::Class::ResultSet; use strict; use warnings; use overload - '0+' => 'count', + '0+' => \&count, 'bool' => sub { 1; }, fallback => 1; use Data::Page; diff --git a/t/run/16joins.tl b/t/run/16joins.tl index b9ebeb4..8c8378b 100644 --- a/t/run/16joins.tl +++ b/t/run/16joins.tl @@ -73,7 +73,7 @@ my $rs = $schema->resultset("CD")->search( ] ] } ); -cmp_ok( $rs->count, '==', 1, "Single record in resultset"); +cmp_ok( $rs + 0, '==', 1, "Single record in resultset"); is($rs->first->title, 'Forkful of bees', 'Correct record returned'); @@ -81,7 +81,7 @@ $rs = $schema->resultset("CD")->search( { 'year' => 2001, 'artist.name' => 'Caterwauler McCrae' }, { join => 'artist' }); -cmp_ok( $rs->count, '==', 1, "Single record in resultset"); +cmp_ok( $rs + 0, '==', 1, "Single record in resultset"); is($rs->first->title, 'Forkful of bees', 'Correct record returned'); @@ -90,7 +90,7 @@ $rs = $schema->resultset("CD")->search( 'liner_notes.notes' => 'Kill Yourself!' }, { join => [ qw/artist liner_notes/ ] }); -cmp_ok( $rs->count, '==', 1, "Single record in resultset"); +cmp_ok( $rs + 0, '==', 1, "Single record in resultset"); is($rs->first->title, 'Come Be Depressed With Us', 'Correct record returned'); @@ -114,7 +114,7 @@ $rs = $schema->resultset("CD")->search( { prefetch => [ qw/artist liner_notes/ ], order_by => 'me.cdid' }); -cmp_ok($rs->count, '==', 3, 'Correct number of records returned'); +cmp_ok($rs + 0, '==', 3, 'Correct number of records returned'); # start test for prefetch SELECT count unlink 't/var/dbic.trace' if -e 't/var/dbic.trace';