From: Matt S Trout Date: Sun, 10 Jun 2007 16:10:37 +0000 (+0000) Subject: fix page-within-page bug X-Git-Tag: v0.08010~150^2~14 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4d993a620321bb32e79b8e79565c051e97d095c0;p=dbsrgits%2FDBIx-Class.git fix page-within-page bug --- diff --git a/Changes b/Changes index ec629fa..0a17b9f 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,7 @@ Revision history for DBIx::Class + - fixed page-within-page bug (reported by nilsonsfj) + 0.07999_05 2007-06-07 23:00:00 - Made source_name rw in ResultSource - Fixed up SQL::Translator test/runtime dependencies diff --git a/lib/DBIx/Class/ResultSet.pm b/lib/DBIx/Class/ResultSet.pm index 315666b..1bfd6d0 100644 --- a/lib/DBIx/Class/ResultSet.pm +++ b/lib/DBIx/Class/ResultSet.pm @@ -91,8 +91,7 @@ sub new { if ($attrs->{page}) { $attrs->{rows} ||= 10; - $attrs->{offset} ||= 0; - $attrs->{offset} += ($attrs->{rows} * ($attrs->{page} - 1)); + $attrs->{offset} ||= ($attrs->{rows} * ($attrs->{page} - 1)); } $attrs->{alias} ||= 'me'; diff --git a/t/67pager.t b/t/67pager.t index 267927d..6abea95 100644 --- a/t/67pager.t +++ b/t/67pager.t @@ -7,7 +7,7 @@ use DBICTest; my $schema = DBICTest->init_schema(); -plan tests => 12; +plan tests => 13; # first page my $it = $schema->resultset("CD")->search( @@ -68,3 +68,11 @@ is( $it->count, 2, "software count on paged rs ok" ); is( $it->next->title, "Generic Manufactured Singles", "software iterator->next ok" ); +# test paging with chained searches +$it = $schema->resultset("CD")->search( + {}, + { rows => 2, + page => 2 } +)->search( undef, { order_by => 'title' } ); + +is( $it->count, 2, "chained searches paging ok" );