[Koha-bugs] [Bug 28479] TestBuilder.pm uses incorrect method for checking if objects to be created exists

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Fri May 28 12:48:39 CEST 2021


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

--- Comment #1 from Joonas Kylmälä <joonas.kylmala at helsinki.fi> ---
Created attachment 121473
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=121473&action=edit
Bug 28479: Use primary keys to check object existence in TestBuilder

The TestBuilder::build_object function used any foreign keys to check
whether an object already exists or not. This brought incorrectly
results of unrelated objects because using any other keys other than
primary keys don't guarantee our results to point to one single
object. For example, as is put here in the unit test, if you created
two items with the same biblionumber and then tried to create a hold
using build_object() we were using the biblionumber to check whether
an item was linked to the hold already. Thus, we were checking whether
a random item was already linked to the hold instead of the one we
wanted either by passing it explicitly to build_object() or the one
build_object() created implicitly. This also resulted in following
warnings when there were more than one match:

DBIx::Class::Storage::DBI::select_single(): Query returned more than
one row.  SQL that returns multiple rows is DEPRECATED for ->find and
->single at /kohadevbox/koha/t/lib/TestBuilder.pm line 235

To test:
 $ prove t/db_dependent

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


More information about the Koha-bugs mailing list