Bugzilla – Attachment 98286 Details for
Bug 24440
Add ->current_item_level_holds to Koha::Acquisition::Order
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24440: (follow-up) Make related objects prefetchable
Bug-24440-follow-up-Make-related-objects-prefetcha.patch (text/plain), 4.84 KB, created by
Jonathan Druart
on 2020-02-03 12:37:40 UTC
(
hide
)
Description:
Bug 24440: (follow-up) Make related objects prefetchable
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2020-02-03 12:37:40 UTC
Size:
4.84 KB
patch
obsolete
>From d47ad17a9f42a4379b0d44109b6e00d6c1f1bc67 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Fri, 31 Jan 2020 00:54:27 -0300 >Subject: [PATCH] Bug 24440: (follow-up) Make related objects prefetchable > >This patch creates aliases for the relations used to retrieve the linked >objects from other tables. It makes the accessor names match the used >relation name, for consistency. > >This is important for code trying to be smart and guessing what needs to >be prefetched, like the API code. > >To test: >1. Run: > $ kshell > k$ prove t/db_dependent/Koha/Acquisition/Order.t >=> SUCCESS: Tests pass >2. Apply this patch >3. Repeat (1) >=> SUCCESS: Tests pass! No behaviour change >4. Verify the POD changes make sense >5. Sign off :-D > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> > >Signed-off-by: David Nind <david@davidnind.com> > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > Koha/Acquisition/Order.pm | 30 +++++++++++++++++++----------- > Koha/Schema/Result/Aqorder.pm | 43 +++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 62 insertions(+), 11 deletions(-) > >diff --git a/Koha/Acquisition/Order.pm b/Koha/Acquisition/Order.pm >index 0eb5c7f3fa..55d720fcc4 100644 >--- a/Koha/Acquisition/Order.pm >+++ b/Koha/Acquisition/Order.pm >@@ -113,43 +113,48 @@ sub add_item { > > =head3 basket > >- my $basket = Koha::Acquisition::Orders->find( $id )->basket; >+ my $basket = $order->basket; > >-Returns the basket associated to the order. >+Returns the I<Koha::Acquisition::Basket> object for the basket associated >+to the order. > > =cut > > sub basket { > my ( $self ) = @_; >- my $basket_rs = $self->_result->basketno; >+ my $basket_rs = $self->_result->basket; > return Koha::Acquisition::Basket->_new_from_dbic( $basket_rs ); > } > > =head3 fund > >- my $fund = $order->fund >+ my $fund = $order->fund; > >-Returns the fund (aqbudgets) associated to the order. >+Returns the I<Koha::Acquisition::Fund> object for the fund (aqbudgets) >+associated to the order. > > =cut > > sub fund { > my ( $self ) = @_; >- my $fund_rs = $self->_result->budget; >+ my $fund_rs = $self->_result->fund; > return Koha::Acquisition::Fund->_new_from_dbic( $fund_rs ); > } > > =head3 invoice > >- my $invoice = $order->invoice >+ my $invoice = $order->invoice; > >-Returns the invoice associated to the order. >+Returns the I<Koha::Acquisition::Invoice> object for the invoice associated >+to the order. >+ >+It returns B<undef> if no linked invoice is found. > > =cut > > sub invoice { > my ( $self ) = @_; >- my $invoice_rs = $self->_result->invoiceid; >+ my $invoice_rs = $self->_result->invoice; > return unless $invoice_rs; > return Koha::Acquisition::Invoice->_new_from_dbic( $invoice_rs ); > } >@@ -158,13 +163,16 @@ sub invoice { > > my $subscription = $order->subscription > >-Returns the subscription associated to the order. >+Returns the I<Koha::Subscription> object for the subscription associated >+to the order. >+ >+It returns B<undef> if no linked subscription is found. > > =cut > > sub subscription { > my ( $self ) = @_; >- my $subscription_rs = $self->_result->subscriptionid; >+ my $subscription_rs = $self->_result->subscription; > return unless $subscription_rs; > return Koha::Subscription->_new_from_dbic( $subscription_rs ); > } >diff --git a/Koha/Schema/Result/Aqorder.pm b/Koha/Schema/Result/Aqorder.pm >index f9f307ceb2..a6ab12cf6a 100644 >--- a/Koha/Schema/Result/Aqorder.pm >+++ b/Koha/Schema/Result/Aqorder.pm >@@ -665,6 +665,18 @@ __PACKAGE__->many_to_many("borrowernumbers", "aqorder_users", "borrowernumber"); > # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:GQEXetlivZm7buQohl8m4A > > __PACKAGE__->belongs_to( >+ "basket", >+ "Koha::Schema::Result::Aqbasket", >+ { "foreign.basketno" => "self.basketno" }, >+ { >+ is_deferrable => 1, >+ join_type => "LEFT", >+ on_delete => "CASCADE", >+ on_update => "CASCADE", >+ }, >+); >+ >+__PACKAGE__->belongs_to( > "biblio", > "Koha::Schema::Result::Biblio", > { 'foreign.biblionumber' => "self.biblionumber" }, >@@ -676,6 +688,37 @@ __PACKAGE__->belongs_to( > }, > ); > >+__PACKAGE__->belongs_to( >+ "fund", >+ "Koha::Schema::Result::Aqbudget", >+ { "foreign.budget_id" => "self.budget_id" }, >+ { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }, >+); >+ >+__PACKAGE__->belongs_to( >+ "invoice", >+ "Koha::Schema::Result::Aqinvoice", >+ { "foreign.invoiceid" => "self.invoiceid" }, >+ { >+ is_deferrable => 1, >+ join_type => "LEFT", >+ on_delete => "SET NULL", >+ on_update => "CASCADE", >+ }, >+); >+ >+__PACKAGE__->belongs_to( >+ "subscription", >+ "Koha::Schema::Result::Subscription", >+ { "foreign.subscriptionid" => "self.subscriptionid" }, >+ { >+ is_deferrable => 1, >+ join_type => "LEFT", >+ on_delete => "CASCADE", >+ on_update => "CASCADE", >+ }, >+); >+ > sub koha_objects_class { > 'Koha::Acquisition::Orders'; > } >-- >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 24440
:
97467
|
97468
|
97491
|
97492
|
98194
|
98195
|
98196
|
98197
|
98205
|
98206
|
98207
|
98208
|
98237
|
98283
|
98284
|
98285
| 98286 |
98287
|
98288