From 8c42a73587988bd0180120505ab92f14d21fadef Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 20 Dec 2023 17:29:30 +0000 Subject: [PATCH] Bug 34324: Add relationship aliases --- Koha/Schema/Result/Ticket.pm | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/Koha/Schema/Result/Ticket.pm b/Koha/Schema/Result/Ticket.pm index abc639a055c..82694bba6ec 100644 --- a/Koha/Schema/Result/Ticket.pm +++ b/Koha/Schema/Result/Ticket.pm @@ -266,6 +266,37 @@ __PACKAGE__->has_many( # Created by DBIx::Class::Schema::Loader v0.07051 @ 2024-05-02 11:36:36 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:8bWiSb7hXPFYRzRzrVG3kw +__PACKAGE__->has_many( + "additional_field_values", + "Koha::Schema::Result::AdditionalFieldValue", + sub { + my ($args) = @_; + + return { + "$args->{foreign_alias}.record_id" => { -ident => "$args->{self_alias}.id" }, + + "$args->{foreign_alias}.field_id" => + { -in => \'(SELECT id FROM additional_fields WHERE tablename="tickets")' }, + }; + }, + { cascade_copy => 0, cascade_delete => 0 }, +); + +__PACKAGE__->has_many( + "extended_attributes", + "Koha::Schema::Result::AdditionalFieldValue", + sub { + my ($args) = @_; + + return { + "$args->{foreign_alias}.record_id" => { -ident => "$args->{self_alias}.id" }, + + "$args->{foreign_alias}.field_id" => + { -in => \'(SELECT id FROM additional_fields WHERE tablename="tickets")' }, + }; + }, + { cascade_copy => 0, cascade_delete => 0 }, +); # You can replace this text with custom code or comments, and it will be preserved on regeneration 1; -- 2.47.0