Discussion:
[jifty-devel] Collection with group_by and count or pager->total_entries
Felix Abraham
2008-06-11 13:48:26 UTC
Permalink
Hi,

I'm using a Collection with group_by, and count or pager-
total_entries don't return the values I would have expected. They
return the number of results I would get without the group_by. This
is the code:

my $children = MyApp::Model::ChildCollection->new();
$children->unlimit;
my $familyalias = $children->join(alias1 => 'main', column1 =>
'family', table2 => MyApp::Model::Family->table, column2 => 'id');
$children->group_by(function => 'CONCAT('.$familyalias.'.id,
main.lastname)');
$children->order_by(alias => 'main', column => 'lastname');
$children->set_page_info( current_page => $page, per_page => 10 );
warn $children->count;
warn $children->pager->total_entries;

Using $children->next I get the right number of results. Is there a
way to make the pager use the group_by, too?

Thanks for your help,

Felix

Loading...