Bug 35963 - Problem using some filters in the bundled items table
Summary: Problem using some filters in the bundled items table
Status: Pushed to oldstable
Alias: None
Product: Koha
Classification: Unclassified
Component: Cataloging (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal
Assignee: Julian Maurice
QA Contact: Martin Renvoize (ashimema)
URL:
Keywords:
Depends on: 28854
Blocks:
  Show dependency treegraph
 
Reported: 2024-01-31 15:43 UTC by Julian Maurice
Modified: 2024-07-25 11:11 UTC (History)
4 users (show)

See Also:
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:


Attachments
Bug 35963: Fix bundled items table ordering and filtering (4.13 KB, patch)
2024-02-07 15:02 UTC, Julian Maurice
Details | Diff | Splinter Review
Bug 35963: Add tests (1.78 KB, patch)
2024-02-28 04:56 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 35963: Fix bundled items table ordering and filtering (2.72 KB, patch)
2024-02-28 04:56 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 35963: (QA follow-up): tidy up code and fix exec permission (1.24 KB, patch)
2024-02-28 04:56 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 35963: Add tests (1.85 KB, patch)
2024-03-04 16:37 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 35963: Fix bundled items table ordering and filtering (2.79 KB, patch)
2024-03-04 16:37 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 35963: (QA follow-up): tidy up code and fix exec permission (1.30 KB, patch)
2024-03-04 16:38 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
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 2024-03-19 15:30:28 UTC
Backported to 23.05.x for upcoming 23.05.10.