From b010b6905225a64c2e265d92d66365ea1c4a646b Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 12 Apr 2021 16:22:55 +0200 Subject: [PATCH] Bug 21549: Make filter_by_last_update returns a Koha::Objects-based object Signed-off-by: Marcel de Rooy Signed-off-by: Jonathan Druart --- Koha/Objects.pm | 2 +- t/db_dependent/Koha/Objects.t | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Koha/Objects.pm b/Koha/Objects.pm index ed9366c010..fab6f9046d 100644 --- a/Koha/Objects.pm +++ b/Koha/Objects.pm @@ -289,7 +289,7 @@ sub filter_by_last_update { $conditions->{'<='} = $dtf->format_date( $to ); } - return $self->_resultset->search( + return $self->search( { $timestamp_column_name => $conditions } diff --git a/t/db_dependent/Koha/Objects.t b/t/db_dependent/Koha/Objects.t index 8e046e9afc..554b631741 100755 --- a/t/db_dependent/Koha/Objects.t +++ b/t/db_dependent/Koha/Objects.t @@ -1097,6 +1097,10 @@ subtest "filter_by_last_update" => sub { ); }; + my $filtered_patrons = $patrons->filter_by_last_update( + { timestamp_column_name => 'updated_on', days => 2 } ); + is( ref($filtered_patrons), 'Koha::Patrons', 'filter_by_last_update must return a Koha::Objects-based object' ); + my $count = $patrons->filter_by_last_update( { timestamp_column_name => 'updated_on', days => 2 } )->count; is( $count, 3, '3 patrons have been updated before the last 2 days (exclusive)' ); -- 2.39.5