[Bast-commits] r6701 - in DBIx-Class/0.08/trunk: lib/DBIx/Class t
caelum at dev.catalyst.perl.org
caelum at dev.catalyst.perl.org
Wed Jun 17 17:50:48 GMT 2009
Author: caelum
Date: 2009-06-17 17:50:47 +0000 (Wed, 17 Jun 2009)
New Revision: 6701
Modified:
DBIx-Class/0.08/trunk/lib/DBIx/Class/ResultSet.pm
DBIx-Class/0.08/trunk/t/67pager.t
Log:
fix page with offset bug
Modified: DBIx-Class/0.08/trunk/lib/DBIx/Class/ResultSet.pm
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class/ResultSet.pm 2009-06-17 14:30:08 UTC (rev 6700)
+++ DBIx-Class/0.08/trunk/lib/DBIx/Class/ResultSet.pm 2009-06-17 17:50:47 UTC (rev 6701)
@@ -2622,8 +2622,10 @@
$attrs->{collapse} = $collapse;
- if ( $attrs->{page} and not defined $attrs->{offset} ) {
- $attrs->{offset} = ( $attrs->{rows} * ( $attrs->{page} - 1 ) );
+ if ($attrs->{page} && not exists $attrs->{resolved_offset}) {
+ $attrs->{offset} = ($attrs->{rows} * ($attrs->{page} - 1)) +
+ ($attrs->{offset} || 0);
+ $attrs->{resolved_offset} = $attrs->{offset};
}
return $self->{_attrs} = $attrs;
Modified: DBIx-Class/0.08/trunk/t/67pager.t
===================================================================
--- DBIx-Class/0.08/trunk/t/67pager.t 2009-06-17 14:30:08 UTC (rev 6700)
+++ DBIx-Class/0.08/trunk/t/67pager.t 2009-06-17 17:50:47 UTC (rev 6701)
@@ -84,3 +84,19 @@
$schema->default_resultset_attributes({ rows => 5 });
is($p->(), 5, 'default rows is 5');
+
+# test page with offset
+$it = $schema->resultset('CD')->search({}, {
+ rows => 2,
+ page => 2,
+ offset => 1,
+ order_by => 'cdid'
+});
+
+my $row = $schema->resultset('CD')->search({}, {
+ order_by => 'cdid',
+ offset => 3,
+ rows => 1
+})->single;
+
+is($row->cdid, $it->first->cdid, 'page with offset');
More information about the Bast-commits
mailing list