Bugzilla – Attachment 87751 Details for
Bug 22683
Make issue and old_issue prefetchable from Koha::Account::Line
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 22683: Allow prefetch with Koha::Account::Line->checkouts
Bug-22683-Allow-prefetch-with-KohaAccountLine-chec.patch (text/plain), 2.66 KB, created by
Martin Renvoize (ashimema)
on 2019-04-11 08:33:38 UTC
(
hide
)
Description:
Bug 22683: Allow prefetch with Koha::Account::Line->checkouts
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2019-04-11 08:33:38 UTC
Size:
2.66 KB
patch
obsolete
>From 9bcb6f26a1dac6b84ffcf4fca2481833f9feb48f Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Thu, 11 Apr 2019 09:31:15 +0100 >Subject: [PATCH] Bug 22683: Allow prefetch with Koha::Account::Line->checkouts > >This patch adds the required DBIC side relationships for the >Koha::Account::Line checkouts relationship accessor to support >prefetching and also updates the method to enable the capability. > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > Koha/Account/Line.pm | 10 ++++--- > Koha/Schema/Result/Accountline.pm | 44 +++++++++++++++++++++++++++++++ > 2 files changed, 50 insertions(+), 4 deletions(-) > >diff --git a/Koha/Account/Line.pm b/Koha/Account/Line.pm >index ef9f4f9063..4e9a6f655b 100644 >--- a/Koha/Account/Line.pm >+++ b/Koha/Account/Line.pm >@@ -62,11 +62,13 @@ Return the checkout linked to this account line if exists > > sub checkout { > my ( $self ) = @_; >- return unless $self->issue_id ; >+ return unless $self->issue_id; >+ my $issue_rs = $self->_result->issue; >+ return Koha::Checkout->_new_from_dbic( $issue_rs ) if $issue_rs; > >- $self->{_checkout} ||= Koha::Checkouts->find( $self->issue_id ); >- $self->{_checkout} ||= Koha::Old::Checkouts->find( $self->issue_id ); >- return $self->{_checkout}; >+ my $old_issue_rs = $self->_result->old_issue; >+ return Koha::Old::Checkout->_new_from_dbic( $old_issue_rs ) if $old_issue_rs; >+ return undef; > } > > =head3 void >diff --git a/Koha/Schema/Result/Accountline.pm b/Koha/Schema/Result/Accountline.pm >index aa204d4fa1..767ff1e76a 100644 >--- a/Koha/Schema/Result/Accountline.pm >+++ b/Koha/Schema/Result/Accountline.pm >@@ -279,4 +279,48 @@ sub koha_object_class { > 'Koha::Account::Line'; > } > >+=head2 issue >+ >+Type: belongs_to >+ >+Related object: L<Koha::Schema::Result::Issue> >+ >+Note: This DBIC only relationship should be removed (as it will get automatically recreated) >+if we add a proper foreign key for accountlines.issue_id >+ >+=cut >+ >+__PACKAGE__->belongs_to( >+ "issue", >+ "Koha::Schema::Result::Issue", >+ { "foriegn.issue_id" => "self.issue_id" }, >+ { >+ is_deferrable => 1, >+ join_type => "LEFT" >+ }, >+); >+ >+=head2 old_issue >+ >+Type: belongs_to >+ >+Related object: L<Koha::Schema::Result::OldIssue> >+ >+Note: This DBIC only relationship should be removed (as it will get automatically recreated) >+if we add a proper foreign key for accountlines.issue_id >+ >+=cut >+ >+__PACKAGE__->belongs_to( >+ "old_issue", >+ "Koha::Schema::Result::OldIssue", >+ { "foriegn.issue_id" => "self.issue_id" }, >+ { >+ is_deferrable => 1, >+ join_type => "LEFT", >+ on_delete => "SET NULL", >+ on_update => "CASCADE", >+ }, >+); >+ > 1; >-- >2.20.1
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 22683
:
87751
|
88061
|
88062
|
88147