[Koha-bugs] [Bug 25296] Add a way to force an empty Koha::Objects resultset
bugzilla-daemon at bugs.koha-community.org
bugzilla-daemon at bugs.koha-community.org
Wed Apr 29 21:30:48 CEST 2020
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=25296
--- Comment #21 from Tomás Cohen Arazi <tomascohen at gmail.com> ---
(In reply to Jonathan Druart from comment #19)
> I am wondering if we should not force ->empty to be called only as a class
> method.
>
> my $patrons = Koha::Patrons->search;
> $patrons->empty; # Does not really make sense to me.
It would be:
my $patrons_rs = Koha::Patrons->new->empty;
but I get the point.
In the context of bug 25297, it really looks like an unnecessary extra line.
I still feel uncomfortable with the magic instantiation that happens in
->search (and now in ->empty).
my $rs = Koha::Things->new;
$rs->search( $condition_1 ) if $condition_1;
$rs->search( $condition_2 ) if $condition_2;
while ( my $res = $rs->next ) {...}
it is easier to understand (conceptually, for me) than
my $rs = Koha::Things->search( $condition_1 );
$rs->search( $condition_2 ) if $condition_2;
while ( my $res = $rs->next ) {...}
even if you save one line of code (or a ->new on the same line even)...
In this case I opted to not be rigid on my POV and implemented both behaviours,
but I think it is worth discussing in a broader place, if you think some
guideline needs to be generally adopted.
--
You are receiving this mail because:
You are watching all bug changes.
More information about the Koha-bugs
mailing list