Koha::Biblio->host_items fails with search_ordered() because of ambiguous column 'itemnumber' in where clause. It must use me.itemnumber like in Koha::Biblio->items
Used for example in Bug 24192
Created attachment 163131 [details] [review] Bug 36317: Koha::Biblio->host_items must use me.itemnumber Koha::Biblio->host_items fails with search_ordered() because of ambiguous column 'itemnumber' in where clause. It must use me.itemnumber like in Koha::Biblio->items Test plan : prove t/db_dependent/Biblio.t
Created attachment 163155 [details] [review] Bug 36317: Koha::Biblio->host_items must use me.itemnumber Koha::Biblio->host_items fails with search_ordered() because of ambiguous column 'itemnumber' in where clause. It must use me.itemnumber like in Koha::Biblio->items Test plan : prove t/db_dependent/Biblio.t Signed-off-by: David Nind <david@davidnind.com>
Biblio.t passes with and without this patch. Please extend the test to show that this patch resolves the issue.
Ah mistake, it is t/db_dependent/Koha/Biblio.t I'm on adding a UT
Created attachment 163334 [details] [review] Bug 36317: Add unit test If fails it shows : DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::mysql::st execute failed: Column 'itemnumber' in where clause is ambiguous at /kohadevbox/koha/Koha/Objects.pm line 399
Created attachment 163335 [details] [review] Bug 36317: Koha::Biblio->host_items must use me.itemnumber Koha::Biblio->host_items fails with search_ordered() because of ambiguous column 'itemnumber' in where clause. It must use me.itemnumber like in Koha::Biblio->items Test plan : prove t/db_dependent/Biblio.t Signed-off-by: David Nind <david@davidnind.com>
(In reply to Fridolin Somers from comment #6) > Created attachment 163334 [details] [review] [review] > Bug 36317: Add unit test > > If fails it shows : > DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::mysql::st > execute failed: Column 'itemnumber' in where clause is ambiguous at > /kohadevbox/koha/Koha/Objects.pm line 399 Combining Koha::Biblio->host_items with Koha::Items->search_ordered in test suite was too hard. I've done a simpler join on an item transfer which fails on current master. Note that I test with MariaDB 10.6. Looks like it is more severe on join than lower versions.
Created attachment 163338 [details] [review] Bug 36317: Koha::Biblio->host_items must use me.itemnumber Koha::Biblio->host_items fails with search_ordered() because of ambiguous column 'itemnumber' in where clause. It must use me.itemnumber like in Koha::Biblio->items Test plan : prove t/db_dependent/Koha/Biblio.t Signed-off-by: David Nind <david@davidnind.com>
Working on this I learned that DBIx combines several searches into one : Koha::Items->search( { itemnumber => 123 } )->search( {}, { join => 'branchtransfers' } ); Will give only one SQL query : SELECT * FROM items JOIN branchtransfers USING itemnumber WHERE itemnumber='123' So we should always use explicit "me" : Koha::Items->search( { "me.itemnumber" => 123 } )->search( {}, { join => 'branchtransfers' } );
Created attachment 164238 [details] [review] Bug 36317: Add unit test If fails it shows : DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::mysql::st execute failed: Column 'itemnumber' in where clause is ambiguous at /kohadevbox/koha/Koha/Objects.pm line 399 Signed-off-by: Emmi Takkinen <emmi.takkinen@koha-suomi.fi>
Created attachment 164239 [details] [review] Bug 36317: Koha::Biblio->host_items must use me.itemnumber Koha::Biblio->host_items fails with search_ordered() because of ambiguous column 'itemnumber' in where clause. It must use me.itemnumber like in Koha::Biblio->items Test plan : prove t/db_dependent/Koha/Biblio.t Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Emmi Takkinen <emmi.takkinen@koha-suomi.fi>
How is this failure encountered? Or is this the base for another bug? 1 - Enable EasyAnalyticalRecords 2 - Go to a records details page and copy a barcode 3 - Go to another record 4 - Edit -> Link to host record 5 - Enter the barcode 6 - Records are now linked, and display with no error
(In reply to Nick Clemens from comment #13) > How is this failure encountered? Or is this the base for another bug? > > 1 - Enable EasyAnalyticalRecords > 2 - Go to a records details page and copy a barcode > 3 - Go to another record > 4 - Edit -> Link to host record > 5 - Enter the barcode > 6 - Records are now linked, and display with no error Currently there is no failure but there is a good chance in the future. For example Bug 24192 wants to add : $dat->{ITEM_RESULTS} = $biblio->host_items->search_ordered;
Could QA have another look please ?