This is not a DBIx::Class method, but we can provide it for Koha::Objects using slice.
Created attachment 61625 [details] [review] Bug 18332: Add the Koha::Objects->last method DBIx::Class does not provide such method, but it can be handy in some cases. Test plan: prove t/db_dependent/Koha/Objects.t should return green
Created attachment 61626 [details] [review] Bug 18332: Add the Koha::Objects->last method DBIx::Class does not provide such method, but it can be handy in some cases. Test plan: prove t/db_dependent/Koha/Objects.t should return green
Created attachment 61636 [details] [review] Bug 18332: Add the Koha::Objects->last method DBIx::Class does not provide such method, but it can be handy in some cases. Test plan: prove t/db_dependent/Koha/Objects.t should return green Test returned green. Signed-off-by: Marc Véron <veron@veron.ch>
Created attachment 61694 [details] [review] Bug 18332: Add the Koha::Objects->last method DBIx::Class does not provide such method, but it can be handy in some cases. Test plan: prove t/db_dependent/Koha/Objects.t should return green Test returned green. Signed-off-by: Marc Véron <veron@veron.ch> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
+ my $result = $self->_resultset->slice($count - 1, $count)->first; Why do not do this: my ( $result ) = $self->_resultset->slice($count - 1, $count - 1); Strictly speaking, you call slice with an invalid argument; since the index starts at 0, $count is past the last element. Instead of calling in scalar context and doing first, you should call in list context? Adding a follow-up.
Created attachment 61751 [details] [review] Bug 18332: [QA Follow-up] Adjust slice call in last method We should call slice in list context with the correct indexes. Test plan: Run t/db_dependent/Koha/Objects.t Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Pushed to master for 17.05, thanks Jonathan, Marcel!
This won't get ported back to 16.11.x as it is an enhancement.