Bugzilla – Attachment 64740 Details for
Bug 18605
Remove TRUNCATE from C4/HoldsQueue.pm
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[SIGNED-OFF] Bug 18605: Remove TRUNCATE from C4/HoldsQueue.pm
SIGNED-OFF-Bug-18605-Remove-TRUNCATE-from-C4HoldsQ.patch (text/plain), 2.69 KB, created by
Mark Tompsett
on 2017-06-30 02:40:01 UTC
(
hide
)
Description:
[SIGNED-OFF] Bug 18605: Remove TRUNCATE from C4/HoldsQueue.pm
Filename:
MIME Type:
Creator:
Mark Tompsett
Created:
2017-06-30 02:40:01 UTC
Size:
2.69 KB
patch
obsolete
>From 77b301ada78b13b54a6310517efd9800c7721faa Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Mon, 15 May 2017 10:38:43 +0200 >Subject: [PATCH] [SIGNED-OFF] Bug 18605: Remove TRUNCATE from C4/HoldsQueue.pm > >Replaces TRUNCATE by DELETE, since truncate implicitly commits. We don't >need to do that here. (Would complicate testing it too.) >Fixes typo disablig. >Add a simple test to HoldsQueue.t. > >Test plan: >Run t/db_dependent/HoldsQueue.t > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> > >Signed-off-by: Mark Tompsett <mtompset@hotmail.com> >--- > C4/HoldsQueue.pm | 4 ++-- > t/db_dependent/HoldsQueue.t | 12 +++++++++++- > 2 files changed, 13 insertions(+), 3 deletions(-) > >diff --git a/C4/HoldsQueue.pm b/C4/HoldsQueue.pm >index 0f2ad221a2..07c0d9ceb2 100755 >--- a/C4/HoldsQueue.pm >+++ b/C4/HoldsQueue.pm >@@ -100,7 +100,7 @@ sub UpdateTransportCostMatrix { > > my $sth = $dbh->prepare("INSERT INTO transport_cost (frombranch, tobranch, cost, disable_transfer) VALUES (?, ?, ?, ?)"); > >- $dbh->do("TRUNCATE TABLE transport_cost"); >+ $dbh->do("DELETE FROM transport_cost"); > foreach (@$records) { > my $cost = $_->{cost}; > my $from = $_->{frombranch}; >@@ -109,7 +109,7 @@ sub UpdateTransportCostMatrix { > $cost ||= 0; > } > elsif ( !defined ($cost) || ($cost !~ m/(0|[1-9][0-9]*)(\.[0-9]*)?/o) ) { >- warn "Invalid $from -> $to cost $cost - must be a number >= 0, disablig"; >+ warn "Invalid $from -> $to cost $cost - must be a number >= 0, disabling"; > $cost = 0; > $_->{disable_transfer} = 1; > } >diff --git a/t/db_dependent/HoldsQueue.t b/t/db_dependent/HoldsQueue.t >index 3f9d3bd6c7..d4088a8309 100755 >--- a/t/db_dependent/HoldsQueue.t >+++ b/t/db_dependent/HoldsQueue.t >@@ -8,7 +8,7 @@ > > use Modern::Perl; > >-use Test::More tests => 43; >+use Test::More tests => 44; > use Data::Dumper; > > use C4::Calendar; >@@ -724,6 +724,16 @@ C4::HoldsQueue::CreateQueue(); > my $queue_rs = $schema->resultset('TmpHoldsqueue'); > is( $queue_rs->count(), 1, "Hold queue contains one hold from chosen from three possible items" ); > >+subtest 'Trivial test for UpdateTransportCostMatrix' => sub { >+ plan tests => 1; >+ my $recs = [ >+ { frombranch => $library1->{branchcode}, tobranch => $library2->{branchcode} , cost => 1, disable_transfer => 0 }, >+ { frombranch => $library2->{branchcode}, tobranch => $library3->{branchcode}, cost => 0, disable_transfer => 1 }, >+ ]; >+ C4::HoldsQueue::UpdateTransportCostMatrix( $recs ); >+ is( $schema->resultset('TransportCost')->count, 2, 'UpdateTransportCostMatrix added two records' ); >+}; >+ > # Cleanup > $schema->storage->txn_rollback; > >-- >2.11.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 18605
:
63462
|
64740
|
65174