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> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
parent
a905fd8a38
commit
ffb5fb60ed
|
|
@ -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 );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -664,6 +664,18 @@ __PACKAGE__->many_to_many("borrowernumbers", "aqorder_users", "borrowernumber");
|
|||
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-08-31 11:51:37
|
||||
# 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",
|
||||
|
|
@ -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';
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue