From ff8bdc502ee9853854e50d0658b91ea16193ca73 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 2 Jul 2026 11:45:44 +0200 Subject: [PATCH] Bug 42979: Prevent failure on My8 In MySQL8 the order on the PK is not preserved. We need to explicitely pass it. Test plan: export DB_IMAGE=mysql:8.0; then startup ktd % prove t/db_dependent/api/v1/biblios.t should pass with this patch Without this patch it failed with: 13:00:29 # Failed test 'exact match for JSON Pointer "/4/item_id"' 13:00:29 # at t/db_dependent/api/v1/biblios.t line 276. 13:00:34 # got: '3420' 13:00:36 # expected: '3417' 13:00:37 13:00:38 # Failed test 'Withdrawn comes after lost' 13:00:57 # at t/db_dependent/api/v1/biblios.t line 276. 13:00:59 # got: '3417' 13:01:04 # expected: '3420' 13:01:05 # Looks like you failed 2 tests of 8. Signed-off-by: David Nind Signed-off-by: Jan Kissig Signed-off-by: Pedro Amorim --- Koha/REST/V1/Biblios.pm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Koha/REST/V1/Biblios.pm b/Koha/REST/V1/Biblios.pm index 49f1443397..f8e7713da9 100644 --- a/Koha/REST/V1/Biblios.pm +++ b/Koha/REST/V1/Biblios.pm @@ -276,7 +276,9 @@ sub get_items { qw( available checked_out local_use in_transit lost withdrawn damaged not_for_loan on_hold recalled in_bundle restricted ) ) { - push @item_ids, $items_rs->search( { _status => $status } )->get_column('itemnumber'); + push @item_ids, + $items_rs->search( { _status => $status }, { order_by => { '-asc' => 'me.itemnumber' } } ) + ->get_column('itemnumber'); } $items_rs = $items_rs->search( {},