[Jifty-commit] r4641 - in Jifty-DBI/trunk: lib/Jifty/DBI
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Fri Dec 7 16:17:59 EST 2007
Author: jesse
Date: Fri Dec 7 16:17:58 2007
New Revision: 4641
Modified:
Jifty-DBI/trunk/ (props changed)
Jifty-DBI/trunk/lib/Jifty/DBI/Collection.pm
Log:
r72497 at pinglin: jesse | 2007-11-30 00:16:53 -0500
* Be a bit cleverer about not always doing a count before doing a select
(The previous behaviour was pathalogical)
Modified: Jifty-DBI/trunk/lib/Jifty/DBI/Collection.pm
==============================================================================
--- Jifty-DBI/trunk/lib/Jifty/DBI/Collection.pm (original)
+++ Jifty-DBI/trunk/lib/Jifty/DBI/Collection.pm Fri Dec 7 16:17:58 2007
@@ -2,6 +2,7 @@
use warnings;
use strict;
+use Scalar::Defer qw/lazy/;
=head1 NAME
@@ -1746,12 +1747,14 @@
);
return if $self->derived;
- $self->pager->total_entries( $self->count_all )
+ $self->pager->total_entries( lazy { $self->count_all } )
->entries_per_page( $args{'per_page'} )
->current_page( $args{'current_page'} );
$self->rows_per_page( $args{'per_page'} );
- $self->first_row( $self->pager->first || 1 );
+ # We're not using $pager->first because it automatically does a count_all
+ # to correctly return '0' for empty collections
+ $self->first_row((($self->pager->current_page - 1) * $self->pager->entries_per_page) + 1);
}
More information about the Jifty-commit
mailing list