[Koha-bugs] [Bug 28561] Order_by triggers a DBIx warning Unable to properly collapse has_many results

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Mon Jun 14 15:45:50 CEST 2021


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

--- Comment #3 from Marcel de Rooy <m.de.rooy at rijksmuseum.nl> ---
Created attachment 121912
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=121912&action=edit
Bug 28561: Resolve DBIx's Unable to collapse results-warning

[WARN] DBIx::Class::ResultSet::_construct_results(): Unable to properly
collapse has_many results in iterator mode due to order criteria - performed an
eager cursor slurp underneath. Consider using ->all() instead at
/usr/share/koha/Koha/Objects.pm line 335

DBIx tells:
If an "order_by" is already declared, and orders the resultset in a way that
makes collapsing as described above impossible (e.g. ORDER BY
has_many_rel.column or ORDER BY RANDOM()), DBIC will automatically switch to
"eager" mode and slurp the entire resultset before constructing the first
object returned by "next".

The query in opac-shelves here prefetches biblio, biblioitems and items.
May order by itemcallnumber (so that is a has_many column). Note that
ordering biblio records (having multiple items) by itemcallnumber
is formally impossible.

This patch pragmatically removes the order_by clause, but I am open
for a better solution ;)

Test plan:
Pick a list with biblios having multiple items.
Show the list in OPAC. Change the sortfield.
Check your plack-opac-error.log.

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


More information about the Koha-bugs mailing list