Skip to content

Commit

Permalink
support HRI'd resultsets
Browse files Browse the repository at this point in the history
  • Loading branch information
wesQ3 authored and Arthur Axel 'fREW' Schmidt committed Nov 3, 2014
1 parent e63de95 commit 9d15337
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
1 change: 1 addition & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Revision history for {{$dist->name}}

{{$NEXT}}
- Transparently support resultsets using HRI (Wes Malone)

0.001001 2013-05-31 23:00:29 CST6CDT
- Remove unneeded dep on parent.pm
Expand Down
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 9d15337

Please sign in to comment.