Bug 27892

Summary: api/v1/acquisitions_vendors.t is failing randomly
Product: Koha Reporter: Jonathan Druart <jonathan.druart>
Component: Test SuiteAssignee: Chris Cormack <chris>
Status: NEW --- QA Contact: Testopia <testopia>
Severity: minor    
Priority: P5 - low CC: tomascohen
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:
Bug Depends on: 7736    
Bug Blocks: 25551    

Description Jonathan Druart 2021-03-08 10:22:38 UTC
10:51:09 koha_1       | #   Failed test 'No tests run for subtest "list() and delete() tests | authorized user"'
10:51:09 koha_1       | #   at t/db_dependent/api/v1/acquisitions_vendors.t line 112.
10:51:09 koha_1       | DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::mysql::st execute failed: Cannot delete or update a parent row: a foreign key constraint fails (`koha_kohadev`.`vendor_edi_accounts`, CONSTRAINT `vfk_vendor_id` FOREIGN KEY (`vendor_id`) REFERENCES `aqbooksellers` (`id`)) [for Statement "DELETE FROM `aqbooksellers`"] at /kohadevbox/koha/Koha/Objects.pm line 208
10:51:09 koha_1       | # Looks like your test exited with 255 just after 1.

Master_D9 (#1590)

Looks like we are missing a "on delete cascade" on vendor_edi_accounts
Comment 1 Tomás Cohen Arazi 2021-03-08 10:39:01 UTC
The easy fix would be to call:

$schema->resultset('VendorEdiAccount')->search->delete;

but are we hiding some error?

On the other hand, we might want the query to fail, so we can notify deleting is not possible and user intervention is needed (i.e. maybe we really want Koha::Acquisition::Booksellers->search->delete to fail).
Comment 2 Katrin Fischer 2023-07-01 18:08:23 UTC
This is 2 years old - still valid?
Comment 3 Jonathan Druart 2023-07-04 08:43:53 UTC
(In reply to Katrin Fischer from comment #2)
> This is 2 years old - still valid?

Yes.