[Koha-bugs] [Bug 28871] Koha::Objects->empty doesn't work correctly in list context

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Tue Nov 2 13:32:12 CET 2021


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28871

--- Comment #16 from Tomás Cohen Arazi <tomascohen at gmail.com> ---
(In reply to Marcel de Rooy from comment #15)
> (In reply to Tomás Cohen Arazi from comment #0)
> > To test:
> > my @patrons = Koha::Patrons->new->empty;
> > Dumper(@patrons);
> 
> What is the practical use of doing so?

You should git grep '\->empty'

The existence of ->empty is meant for consistency in results, and also to avoid
querying the DB for empty results when we know in advance that we need an empty
resultset.

> I would prefer my @patrons;

Right, but my example was too simple. Sometimes ->empty is called implicitly
somewhere else, far from the code you're looking at.

> Was there some intention to use empty with chaining?

empty is there so you don't need to do things like:

if ( $result->count > 0 ) {
    $result = $result->filter_by_something_else;
}

you just chain your queries and know it will work...

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list