Bug 33403 - Letters.t: Foreign key exception if you do not have a numberpattern with id=1
Summary: Letters.t: Foreign key exception if you do not have a numberpattern with id=1
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Test Suite (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal (vote)
Assignee: Jonathan Druart
QA Contact: Marcel de Rooy
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-04-04 13:13 UTC by Marcel de Rooy
Modified: 2023-12-28 20:44 UTC (History)
1 user (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
23.05.00,22.11.06


Attachments
Bug 33403: Fix Letters.t if number pattern with id=1 does not exist (2.34 KB, patch)
2023-05-10 10:35 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 33403: Fix Letters.t if number pattern with id=1 does not exist (2.43 KB, patch)
2023-05-10 11:06 UTC, Marcel de Rooy
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Marcel de Rooy 2023-04-04 13:13:48 UTC
Letters.t

$dbh->do(q|UPDATE subscription_numberpatterns SET numberingmethod='No. {X}' WHERE id=1|);

t/db_dependent/Letters.t .. 51/85 DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::mysql::st execute failed: Cannot add or update a child row: a foreign key constraint fails (`koha_myclone`.`subscription`, CONSTRAINT `subscription_ibfk_2` FOREIGN KEY (`numberpattern`) REFERENCES `subscription_numberpatterns` (`id`) ON DELETE SET NULL ON UPDATE CASCADE) at /usr/share/koha/Koha/Object.pm line 170

Hmm. You should have a record with id=1 in your table. This is bad.
Comment 1 Jonathan Druart 2023-05-10 10:35:35 UTC
Created attachment 150963 [details] [review]
Bug 33403: Fix Letters.t if number pattern with id=1 does not exist

Bad assumption in DB, we should create the data we need

Test plan:
> delete from subscription_numberpatterns;

prove t/db_dependent/Letters.t
Comment 2 Marcel de Rooy 2023-05-10 11:06:50 UTC
Created attachment 150965 [details] [review]
Bug 33403: Fix Letters.t if number pattern with id=1 does not exist

Bad assumption in DB, we should create the data we need

Test plan:
> delete from subscription_numberpatterns;

prove t/db_dependent/Letters.t

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 3 Marcel de Rooy 2023-05-10 11:07:10 UTC
SO + QA
Comment 4 Tomás Cohen Arazi 2023-05-10 18:28:48 UTC
Pushed to master for 23.05.

Nice work everyone, thanks!
Comment 5 Matt Blenkinsop 2023-05-15 12:42:28 UTC
Nice work everyone!

Pushed to stable for 22.11.x