Skip to content

Commit

Permalink
Merge f4a09c8 into e63de95
Browse files Browse the repository at this point in the history
  • Loading branch information
wesQ3 committed Nov 3, 2014
2 parents e63de95 + f4a09c8 commit 748675c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/Web/Util/ExtPaging.pm
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ sub ext_paginate {
}

return ext_parcel(
[map $_->$method, $resultset->all],
$resultset->result_class->isa('DBIx::Class::ResultClass::HashRefInflator') ?
[$resultset->all] :
[map $_->$method, $resultset->all],
$resultset->is_paged
? ($resultset->pager->total_entries)
: (),
Expand Down
22 changes: 22 additions & 0 deletions t/basic.t
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,28 @@ my $rs = $schema->resultset('Stations')->search(undef, {
}, 'ext_paginate with coderef correctly builds structure';
}

{
my $rs = $schema->resultset('Stations')->search(undef, {
columns => ['id'],
order_by => 'id',
rows => 3,
page => 1,
result_class => 'DBIx::Class::ResultClass::HashRefInflator',
});
my $data = ext_paginate($rs);

cmp_deeply $data, {
total => 9,
data=> set({
id => 1,
},{
id => 2,
},{
id => 3,
})
}, 'ext_paginate passes through HRI resultset';
}

{
my $data = ext_parcel(
[ map +{ id => $_->id }, $rs->all ],
Expand Down

0 comments on commit 748675c

Please sign in to comment.