Bugzilla – Attachment 94857 Details for
Bug 14697
Extend and enhance "Claims returned" lost status
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14697: (QA follow-up) Restore FK on issue_id and adjust tests
Bug-14697-QA-follow-up-Restore-FK-on-issueid-and-a.patch (text/plain), 5.06 KB, created by
Tomás Cohen Arazi (tcohen)
on 2019-10-29 20:44:33 UTC
(
hide
)
Description:
Bug 14697: (QA follow-up) Restore FK on issue_id and adjust tests
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2019-10-29 20:44:33 UTC
Size:
5.06 KB
patch
obsolete
>From 9ebad513a4f159445a8b37c249ae0db9c386f063 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Tue, 29 Oct 2019 17:43:13 -0300 >Subject: [PATCH] Bug 14697: (QA follow-up) Restore FK on issue_id and adjust > tests > >This patch reintroduces the FK constraint on issue_id. The tests are >adjusted to reflect the UNIQUE constraint we also added. > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > .../data/mysql/atomicupdate/bug_14697.perl | 3 +- > installer/data/mysql/kohastructure.sql | 3 +- > t/db_dependent/Koha/Checkouts/ReturnClaim.t | 38 ++++++++++++++++--- > 3 files changed, 37 insertions(+), 7 deletions(-) > >diff --git a/installer/data/mysql/atomicupdate/bug_14697.perl b/installer/data/mysql/atomicupdate/bug_14697.perl >index 5fadaf6078..32bb97105b 100644 >--- a/installer/data/mysql/atomicupdate/bug_14697.perl >+++ b/installer/data/mysql/atomicupdate/bug_14697.perl >@@ -17,7 +17,8 @@ if( CheckVersion( $DBversion ) ) { > resolved_by int(11) NULL DEFAULT NULL, > PRIMARY KEY (`id`), > KEY `itemnumber` (`itemnumber`), >- UNIQUE( issue_id ), >+ CONSTRAINT UNIQUE `issue_id` ( issue_id ), >+ CONSTRAINT `issue_id` FOREIGN KEY (`issue_id`) REFERENCES `issues` (`issue_id`) ON DELETE SET NULL ON UPDATE CASCADE, > CONSTRAINT `rc_items_ibfk` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE, > CONSTRAINT `rc_borrowers_ibfk` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE, > CONSTRAINT `rc_created_by_ibfk` FOREIGN KEY (`created_by`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE, >diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql >index a0d03ad385..34ab77bc58 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -4439,7 +4439,8 @@ CREATE TABLE return_claims ( > resolved_by int(11) NULL DEFAULT NULL, > PRIMARY KEY (`id`), > KEY `itemnumber` (`itemnumber`), >- UNIQUE( issue_id ), >+ CONSTRAINT UNIQUE `issue_id` ( issue_id ), >+ CONSTRAINT `issue_id` FOREIGN KEY (`issue_id`) REFERENCES `issues` (`issue_id`) ON DELETE SET NULL ON UPDATE CASCADE, > CONSTRAINT `rc_items_ibfk` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE, > CONSTRAINT `rc_borrowers_ibfk` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE, > CONSTRAINT `rc_created_by_ibfk` FOREIGN KEY (`created_by`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE, >diff --git a/t/db_dependent/Koha/Checkouts/ReturnClaim.t b/t/db_dependent/Koha/Checkouts/ReturnClaim.t >index ebb16b016f..ef03875bad 100644 >--- a/t/db_dependent/Koha/Checkouts/ReturnClaim.t >+++ b/t/db_dependent/Koha/Checkouts/ReturnClaim.t >@@ -30,7 +30,7 @@ my $builder = t::lib::TestBuilder->new; > > subtest "store() tests" => sub { > >- plan tests => 6; >+ plan tests => 8; > > $schema->storage->txn_begin; > >@@ -82,7 +82,7 @@ subtest "store() tests" => sub { > throws_ok { > Koha::Checkouts::ReturnClaim->new( > { >- issue_id => $checkout->id + 1000, >+ issue_id => $checkout->id, > itemnumber => $checkout->itemnumber, > borrowernumber => $checkout->borrowernumber, > notes => 'Some notes', >@@ -90,16 +90,44 @@ subtest "store() tests" => sub { > } > )->store; > } >- 'Koha::Exceptions::Object::FKConstraint', >- 'An exception is thrown on invalid issue_id'; >+ 'Koha::Exceptions::Object::DuplicateID', >+ 'An exception is thrown on duplicate issue_id'; > close STDERR; > > is( >- $@->broken_fk, >+ $@->duplicate_id, > 'issue_id', > 'Exception field is correct' > ); > } > >+ { # hide useless warnings >+ local *STDERR; >+ open STDERR, '>', '/dev/null'; >+ >+ my $another_checkout = $builder->build_object({ class => 'Koha::Checkouts' }); >+ my $checkout_id = $another_checkout->id; >+ $another_checkout->delete; >+ >+ my $THE_claim; >+ >+ throws_ok { >+ $THE_claim = Koha::Checkouts::ReturnClaim->new( >+ { >+ issue_id => $checkout_id, >+ itemnumber => $checkout->itemnumber, >+ borrowernumber => $checkout->borrowernumber, >+ notes => 'Some notes', >+ created_by => $librarian->borrowernumber >+ } >+ )->store; >+ } >+ 'Koha::Exceptions::Object::FKConstraint', >+ 'An exception is thrown on invalid issue_id'; >+ close STDERR; >+ >+ is( $@->broken_fk, 'issue_id', 'Exception field is correct' ); >+ } >+ > $schema->storage->txn_rollback; > }; >-- >2.23.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 14697
:
92407
|
92408
|
92409
|
92410
|
92962
|
92963
|
92964
|
92965
|
93005
|
93006
|
93007
|
93008
|
93012
|
93013
|
93014
|
93015
|
93017
|
93038
|
93039
|
93040
|
93041
|
93042
|
93061
|
93062
|
93063
|
93064
|
93065
|
93952
|
93953
|
93954
|
93955
|
93956
|
93957
|
93959
|
94842
|
94843
|
94844
|
94845
|
94846
|
94847
|
94848
|
94849
|
94850
|
94851
|
94852
|
94853
|
94854
| 94857 |
94877
|
94878