Skip to content

Commit

Permalink
Fix HRI'd resultsets to use coderef if passed
Browse files Browse the repository at this point in the history
  • Loading branch information
Arthur Axel 'fREW' Schmidt committed Mar 30, 2015
1 parent 411995c commit 4edbd2a
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}}
- Fix HRI'd resultsets to use coderef if passed (Good find Nathan Dyck!)

0.001002 2014-11-03 16:21:05-06:00 America/Chicago
- Transparently support resultsets using HRI (Wes Malone)
Expand Down
2 changes: 1 addition & 1 deletion lib/Web/Util/ExtPaging.pm
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ sub ext_paginate {
}

return ext_parcel(
$resultset->result_class->isa('DBIx::Class::ResultClass::HashRefInflator') ?
$resultset->result_class->isa('DBIx::Class::ResultClass::HashRefInflator') && !ref $method ?
[$resultset->all] :
[map $_->$method, $resultset->all],
$resultset->is_paged
Expand Down
24 changes: 24 additions & 0 deletions t/basic.t
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,28 @@ my $rs = $schema->resultset('Stations')->search(undef, {
})
}, 'ext_parcel 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, sub { +{ id => $_[0]{id} + 1 } } );

cmp_deeply $data, {
total => 9,
data=> set({
id => 2,
},{
id => 3,
},{
id => 4,
})
}, 'ext_paginate w/ HRI works with coderef';
}

done_testing;

0 comments on commit 4edbd2a

Please sign in to comment.