From: Matt S Trout Date: Sun, 10 Jun 2007 16:41:57 +0000 (+0000) Subject: slight tweak X-Git-Tag: v0.08010~150^2~13 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a7783df5b755ef1379e91f55974ee86ccc31e0ea;p=dbsrgits%2FDBIx-Class.git slight tweak --- diff --git a/lib/DBIx/Class/ResultSet.pm b/lib/DBIx/Class/ResultSet.pm index 1bfd6d0..8f4a5ba 100644 --- a/lib/DBIx/Class/ResultSet.pm +++ b/lib/DBIx/Class/ResultSet.pm @@ -91,7 +91,6 @@ sub new { if ($attrs->{page}) { $attrs->{rows} ||= 10; - $attrs->{offset} ||= ($attrs->{rows} * ($attrs->{page} - 1)); } $attrs->{alias} ||= 'me'; @@ -936,7 +935,9 @@ sub count { my $count = $self->_count; return 0 unless $count; - $count -= $self->{attrs}{offset} if $self->{attrs}{offset}; + # need to take offset from resolved attrs + + $count -= $self->{_attrs}{offset} if $self->{_attrs}{offset}; $count = $self->{attrs}{rows} if $self->{attrs}{rows} and $self->{attrs}{rows} < $count; return $count; @@ -1894,6 +1895,11 @@ sub _resolved_attrs { } $attrs->{collapse} = $collapse; + if ($attrs->{page}) { + $attrs->{offset} ||= 0; + $attrs->{offset} += ($attrs->{rows} * ($attrs->{page} - 1)); + } + return $self->{_attrs} = $attrs; }