Bug 35963

Summary: Problem using some filters in the bundled items table
Product: Koha Reporter: Julian Maurice <julian.maurice>
Component: CatalogingAssignee: Julian Maurice <julian.maurice>
Status: Pushed to oldstable --- QA Contact: Martin Renvoize (ashimema) <martin.renvoize>
Severity: normal    
Priority: P5 - low CC: fridolin.somers, lucas, m.de.rooy, victor
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
24.05.00,23.11.04,23.05.10
Circulation function:
Bug Depends on: 28854    
Bug Blocks:    
Attachments: Bug 35963: Fix bundled items table ordering and filtering
Bug 35963: Add tests
Bug 35963: Fix bundled items table ordering and filtering
Bug 35963: (QA follow-up): tidy up code and fix exec permission
Bug 35963: Add tests
Bug 35963: Fix bundled items table ordering and filtering
Bug 35963: (QA follow-up): tidy up code and fix exec permission

Description Julian Maurice 2024-01-31 15:43:11 UTC
When trying to use the barcode filter of the bundled items table, the REST API returns an error 500 with the following message in logs:

Unknown column 'me.barcode' in 'where clause' at /usr/share/perl5/Data/Page.pm line 49

The URL looks like this:

/api/v1/items/3/bundled_items?&_page=1&_per_page=20&q=[{"me.external_id":{"like":"%1%"}}]&_match=contains

If I manually remove "me." from the URL, it works.
Comment 1 Julian Maurice 2024-02-07 15:02:09 UTC
Created attachment 161812 [details] [review]
Bug 35963: Fix bundled items table ordering and filtering

Using the many-to-many relationship results in the table alias `me` to
be used for table `item_bundles` instead of the expected table `items`.
This causes ordering and filtering to fail for columns Callnumber and
Barcode.
Using Koha::Items->search does not have this problem.

This patch also disables ordering by status because it does not work
(error message is: "Cannot find Koha::Object class for return_claim'")

Test plan:
1. Create an item bundle
   https://koha-community.org/manual/23.11/en/html/circulation.html#circulating-bundles
2. Add at least 2 items to this bundle
3. Verify that ordering/filtering by callnumber or barcode works
4. Run `prove t/db_dependent/api/v1/items/bundled_items.t`
Comment 2 Victor Grousset/tuxayo 2024-02-28 04:56:25 UTC
Created attachment 162521 [details] [review]
Bug 35963: Add tests

Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Comment 3 Victor Grousset/tuxayo 2024-02-28 04:56:27 UTC
Created attachment 162522 [details] [review]
Bug 35963: Fix bundled items table ordering and filtering

Using the many-to-many relationship results in the table alias `me` to
be used for table `item_bundles` instead of the expected table `items`.
This causes ordering and filtering to fail for columns Callnumber and
Barcode.
Using Koha::Items->search does not have this problem.

This patch also disables ordering by status because it does not work
(error message is: "Cannot find Koha::Object class for return_claim'")

Test plan:
1. Create an item bundle
   https://koha-community.org/manual/23.11/en/html/circulation.html#circulating-bundles
2. Add at least 2 items to this bundle
3. Verify that ordering/filtering by callnumber or barcode works
4. Run `prove t/db_dependent/api/v1/items/bundled_items.t`

Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Comment 4 Victor Grousset/tuxayo 2024-02-28 04:56:29 UTC
Created attachment 162523 [details] [review]
Bug 35963: (QA follow-up): tidy up code and fix exec permission
Comment 5 Victor Grousset/tuxayo 2024-02-28 04:57:22 UTC
It works :)

Also split commit to check that the new tests indeed need the implementation to pass.
Comment 6 Martin Renvoize (ashimema) 2024-03-04 16:37:56 UTC
Created attachment 162718 [details] [review]
Bug 35963: Add tests

Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 7 Martin Renvoize (ashimema) 2024-03-04 16:37:58 UTC
Created attachment 162719 [details] [review]
Bug 35963: Fix bundled items table ordering and filtering

Using the many-to-many relationship results in the table alias `me` to
be used for table `item_bundles` instead of the expected table `items`.
This causes ordering and filtering to fail for columns Callnumber and
Barcode.
Using Koha::Items->search does not have this problem.

This patch also disables ordering by status because it does not work
(error message is: "Cannot find Koha::Object class for return_claim'")

Test plan:
1. Create an item bundle
   https://koha-community.org/manual/23.11/en/html/circulation.html#circulating-bundles
2. Add at least 2 items to this bundle
3. Verify that ordering/filtering by callnumber or barcode works
4. Run `prove t/db_dependent/api/v1/items/bundled_items.t`

Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 8 Martin Renvoize (ashimema) 2024-03-04 16:38:01 UTC
Created attachment 162720 [details] [review]
Bug 35963: (QA follow-up): tidy up code and fix exec permission

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 9 Martin Renvoize (ashimema) 2024-03-04 16:38:27 UTC
Thanks chaps, Passing QA here.
Comment 10 Katrin Fischer 2024-03-07 14:04:14 UTC
Pushed for 24.05!

Well done everyone, thank you!
Comment 11 Fridolin Somers 2024-03-11 09:43:11 UTC
Pushed to 23.11.x for 23.11.04
Comment 12 Lucas Gass (lukeg) 2024-03-19 15:30:28 UTC
Backported to 23.05.x for upcoming 23.05.10.