Koha-clms/t/db_dependent/Koha
Andrii Nugged d64d02761d
Bug 43344: Use the current source alias in filter_by_active
Bug 36018 qualified the quantity column with the default "me" alias to
avoid ambiguity when joined tables also have a quantity column.

DBIx::Class does not always use "me" for related resultsets. The
many-to-many item_orders relationship uses "ordernumber", so evaluating
item.orders.filter_by_active from the OPAC refers to a non-existent
me.quantity column.

Use current_source_alias to qualify quantity with the alias of the actual
resultset. Add regression coverage for filtering active orders through the
item relationship.

Test plan:
Before applying the patch:
1. Set OPACAcquisitionDetails to Show.
2. Set AcqCreateItem to create an item when placing an order.
3. Create a basket and add an order for a bibliographic record, including an
   item.
4. Close the basket so the order is active and outstanding.
5. Open the bibliographic record in the OPAC.
6. Confirm the item is not shown as On order and the log contains an Unknown
   column 'me.quantity' error.

Apply the patch.

After applying the patch:
1. Open the same bibliographic record in the OPAC again.
2. Confirm the item is shown as On order and the SQL error is gone.

Co-Authored-By: Loontik <loontik@nugged.team>
Signed-off-by: Olivia Reynolds <olivia.reynolds@openfifth.co.uk>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
2026-09-09 15:49:59 +00:00
..
Account Bug 40255: (QA follow-up) Adjust test count 2026-04-17 09:18:15 -06:00
Acquisition Bug 43344: Use the current source alias in filter_by_active 2026-09-09 15:49:59 +00:00
Auth Bug 33782: (QA follow-up) Fix qa issues 2026-02-10 10:51:33 -07:00
BackgroundJob Bug 42656: (QA follow-up) Fix dead status code in file_transport_test.inc 2026-08-06 16:05:20 +00:00
BackgroundJobs Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Biblio Bug 42567: Remove C4::Koha::GetNormalizedEAN in favor of MetadataExtractor 2026-08-20 15:34:10 +00:00
Cash Bug 40445: (QA follow-up) Add nonce, POD, and test isolation 2026-07-27 12:12:37 +00:00
Charges Bug 36506: Adjust existing tests and test builder 2026-02-27 11:38:47 -07:00
Checkouts Bug 42391: (follow-up) Restore DB exception warnings in Object::store 2026-07-21 15:40:23 +00:00
CirculationRules Bug 38944: Add Test::NoWarnings to tests no producing warnings 2025-03-13 17:25:03 +01:00
Club Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Config Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Database Bug 43101: Add unit tests 2026-07-27 12:13:04 +00:00
ERM Bug 39438: (follow-up) Remove agreement_id from periods before comparing to result 2026-02-06 07:21:01 -07:00
Edifact Bug 30144: Add unit tests for servicing instructions 2026-08-28 16:36:23 +00:00
File Bug 42656: (QA follow-up) Use _abort_operation() for Local's 'not configured' errors too 2026-08-06 16:05:22 +00:00
Filter Bug 38136: Refactor database translations (alternative) 2026-04-15 11:37:14 -06:00
ILL Bug 42653: Add tests 2026-09-01 15:42:18 +00:00
Import Bug 42764: Fix spelling errors across the codebase 2026-06-03 16:09:04 +00:00
Item Bug 41728: (QA follow-up) Move Item::Checkin::Availability to Item::Availability::Checkin 2026-09-04 11:24:02 +00:00
Items Bug 41884: Adjust tests 2026-04-15 09:14:49 -06:00
Library Bug 28530: Fix tests 2026-02-10 10:51:38 -07:00
Middleware Bug 38365: Fix Koha/Middleware/ContentSecurityPolicy.t 2026-03-17 09:38:50 +01:00
Notice Bug 35267: (follow-up) More comprehensive and db agnostic tests 2026-04-17 09:18:09 -06:00
OAI/Server Bug 37713: (QA follow-up) Add unit tests 2026-04-17 09:18:04 -06:00
Object Bug 32370: (QA follow-up) Add https to license url, use Test::NoWarnings 2026-01-22 10:02:26 -07:00
Objects Bug 35451: Fix test data 2025-11-07 10:54:06 -07:00
Old Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Patron Bug 39658: Tests: Add unit tests for Koha::Patron::AccountLink 2026-09-09 12:07:35 +00:00
Patrons Bug 41145: Add unit test coverage for stopping duplicated borrowerslog logging due to extended patron attributes being deleted on import 2025-12-17 13:24:26 -07:00
Plugins Bug 42653: Add tests 2026-09-01 15:42:18 +00:00
Policy Bug 42529: Prevent the test to fail in the future 2026-08-06 16:07:31 +00:00
Preservation Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
REST Bug 43241: Add tests for datetime/boolean fixup inside DBIC operators 2026-08-28 16:36:35 +00:00
SIP2 Bug 39829: (QA follow-up) Fix test plan count 2026-09-03 10:56:54 +00:00
SMTP Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Schema Bug 42391: (follow-up) Restore DB exception warnings in Object::store 2026-07-21 15:40:23 +00:00
SearchEngine Bug 42485: (QA follow-up) Add explicit JSON::PP import and test coverage 2026-06-12 16:24:16 +00:00
Subscription Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Tags Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Template/Plugin Bug 42564: Fix Template/Plugin/Asset.t 2026-06-24 08:41:31 +00:00
Ticket Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
UI/Form/Builder Bug 38365: Require a non-empty nonce in FrameworkPlugin.t 2026-03-17 09:38:49 +01:00
XSLT Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Z3950Responder Bug 40680: Fix t tests 2025-12-01 08:34:01 -07:00
Account.t Bug 42391: (follow-up) Restore DB exception warnings in Object::store 2026-07-21 15:40:23 +00:00
ActionLogs.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
AdditionalContents.t Bug 42973: (RM follow-up) Update tests number 2026-08-12 15:49:52 +00:00
AdditionalField.t Bug 38944: Add Test::NoWarnings to tests no producing warnings 2025-03-13 17:25:03 +01:00
ApiKey.t Bug 42391: (follow-up) Restore DB exception warnings in Object::store 2026-07-21 15:40:23 +00:00
ArticleRequest.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
ArticleRequests.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Authorities.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Authority.t Bug 41843: Gracefully handle XML errors during authority deletion 2026-04-10 09:48:12 -06:00
BackgroundJob.t Bug 40943: Fix Koha/BackgroundJob.t 2025-11-04 07:15:11 -07:00
BackgroundJobs.t Bug 42394: (QA follow-up) Clean up test 2026-04-17 09:17:59 -06:00
Biblio.t Bug 42997: (QA follow-up) Don't let a booking's own checkout block it in Biblio::check_booking 2026-09-03 15:53:57 +00:00
BiblioFrameworks.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Biblios.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Booking.t Bug 41898: (QA follow-up) Skip clash detection when collecting a booking 2026-07-27 15:53:38 +00:00
Bookings.t Bug 41898: Update tests for new booking status lifecycle 2026-07-27 15:53:35 +00:00
Calendar.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Checkout.t Bug 35612: Add unit test for Koha::Checkout->branch_for_fee_context 2026-02-27 11:38:50 -07:00
Checkouts.t Bug 42764: Fix spelling errors across the codebase 2026-06-03 16:09:04 +00:00
CirculationRules.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Cities.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
ClassSortRules.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
ClassSources.t Bug 42764: Fix spelling errors across the codebase 2026-06-03 16:09:04 +00:00
ClassSplitRules.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Course.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Courses.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
CoverImages.t Bug 33857: Avoid increasing file size while uploading image 2026-03-24 09:55:52 +01:00
CsvProfiles.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
CurbsidePickups.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Database.t Bug 38384: Refactor plugin loading to use lightweight Koha::Plugins::Loader 2026-02-25 07:36:59 -07:00
Desks.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
EDI.t Bug 30144: (QA follow-up) Add EDIFACT_SI authorised values to installer data 2026-08-28 16:36:25 +00:00
Encryption.t Bug 40444: Add a test to ensure all Perl test files use Test::NoWarnings 2025-07-28 16:26:36 -06:00
Hold.t Bug 41410: Unit tests 2026-07-29 15:50:10 +00:00
Holds.t Bug 33364: Prevent Holds to Pull from including items with pending recalls 2026-07-27 12:12:53 +00:00
ImportBatch.t Bug 43168: Add a test 2026-07-31 13:40:22 +00:00
Installer.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Item.t Bug 42997: Warn staff when a due date override runs into the next booking 2026-09-03 15:53:52 +00:00
ItemTypes.t Bug 38136: Refactor database translations (alternative) 2026-04-15 11:37:14 -06:00
Items.t Bug 42349: Adjust tests 2026-07-16 17:05:05 +00:00
KeyboardShortcuts.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Libraries.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Library.t Bug 39482: (follow-up) Adjust tests 2025-12-29 09:56:17 -07:00
MarcOrder.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
MarcSubfieldStructures.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Notice_Util.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Notices.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
OAIHarvester.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
OAIServers.t Bug 42391: (follow-up) Add NotNull, NotInStorage and UnhandledDBError translations 2026-07-20 12:44:54 +00:00
OAI_Sets.t Bug 41462: (QA follow-up) Add basic unit tests and koha_object_class methods 2026-03-26 14:21:26 +01:00
Object.t Bug 42391: (follow-up) Restore DB exception warnings in Object::store 2026-07-21 15:40:23 +00:00
Objects.t Bug 39729: Add tests 2026-07-28 14:32:42 +00:00
Old.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Patron.t Bug 42391: (follow-up) Add missing warning assertions for Object::store 2026-07-27 12:12:29 +00:00
Patron_generate_userid.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Patrons.t Bug 42018: Add unit test 2026-08-14 12:09:36 +00:00
Pseudonymization.t Bug 42396: Adjust 'use' statements 2026-07-27 15:53:23 +00:00
PseudonymizedTransaction.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Quotes.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Ratings.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Recall.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Recalls.t Bug 39985: Set items.onloan when recall adjusts checkout due date 2025-12-01 08:34:05 -07:00
RecordSource.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Reports.t Bug 16631: Bring back template. Fix test syntax. 2026-07-28 14:32:27 +00:00
Reviews.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
SMS_Providers.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
SearchField.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
SearchFilters.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Session.t Bug 38944: Add Test::NoWarnings to tests no producing warnings 2025-03-13 17:25:03 +01:00
SharedContent.t Bug 39745: Fix wrong system preference 'language' in test suite (mock_preference) 2026-01-26 14:36:44 -07:00
Statistic.t Bug 42396: Adjust 'use' statements 2026-07-27 15:53:23 +00:00
Statistics.t Bug 42396: Adjust 'use' statements 2026-07-27 15:53:23 +00:00
Subscription.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Suggestion.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Suggestions.t Bug 42391: (follow-up) Restore DB exception warnings in Object::store 2026-07-21 15:40:23 +00:00
Tags.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Ticket.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Virtualshelf.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Virtualshelves.t Bug 39145: (follow-up) Tidy files 2025-09-29 14:02:26 -06:00
Z3950Servers.t Bug 42391: (follow-up) Add NotNull, NotInStorage and UnhandledDBError translations 2026-07-20 12:44:54 +00:00