[Jifty-commit] r5022 - in Jifty-DBI/branches/tisql: lib/Jifty/DBI

Jifty commits jifty-commit at lists.jifty.org
Tue Feb 5 21:16:44 EST 2008


Author: ruz
Date: Tue Feb  5 21:16:44 2008
New Revision: 5022

Modified:
   Jifty-DBI/branches/tisql/   (props changed)
   Jifty-DBI/branches/tisql/lib/Jifty/DBI/Collection.pm

Log:
 r4642 at cubic-pc (orig r4641):  jesse | 2007-12-08 00:17:58 +0300
  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/branches/tisql/lib/Jifty/DBI/Collection.pm
==============================================================================
--- Jifty-DBI/branches/tisql/lib/Jifty/DBI/Collection.pm	(original)
+++ Jifty-DBI/branches/tisql/lib/Jifty/DBI/Collection.pm	Tue Feb  5 21:16:44 2008
@@ -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