@@ -, +, @@ --- Koha/Schema/Result/Accountline.pm | 4 +--- Koha/Schema/Result/Aqbasket.pm | 4 +--- Koha/Schema/Result/Aqinvoice.pm | 4 +--- Koha/Schema/Result/Aqorder.pm | 5 +---- Koha/Schema/Result/Subscription.pm | 4 +--- 5 files changed, 5 insertions(+), 16 deletions(-) --- a/Koha/Schema/Result/Accountline.pm +++ a/Koha/Schema/Result/Accountline.pm @@ -447,9 +447,7 @@ __PACKAGE__->has_many( return { "$args->{foreign_alias}.record_id" => { -ident => "$args->{self_alias}.accountlines_id" }, - - "$args->{foreign_alias}.field_id" => - { -in => \'(SELECT id FROM additional_fields WHERE tablename LIKE "accountlines:%")' }, + "$args->{foreign_alias}.record_table" => __PACKAGE__->table, }; }, { cascade_copy => 0, cascade_delete => 0 }, --- a/Koha/Schema/Result/Aqbasket.pm +++ a/Koha/Schema/Result/Aqbasket.pm @@ -352,9 +352,7 @@ __PACKAGE__->has_many( return { "$args->{foreign_alias}.record_id" => { -ident => "$args->{self_alias}.basketno" }, - - "$args->{foreign_alias}.field_id" => - { -in => \'(SELECT id FROM additional_fields WHERE tablename = "aqbasket")' }, + "$args->{foreign_alias}.record_table" => __PACKAGE__->table, }; }, { cascade_copy => 0, cascade_delete => 0 }, --- a/Koha/Schema/Result/Aqinvoice.pm +++ a/Koha/Schema/Result/Aqinvoice.pm @@ -228,9 +228,7 @@ __PACKAGE__->has_many( return { "$args->{foreign_alias}.record_id" => { -ident => "$args->{self_alias}.invoiceid" }, - - "$args->{foreign_alias}.field_id" => - { -in => \'(SELECT id FROM additional_fields WHERE tablename="aqinvoices")' }, + "$args->{foreign_alias}.record_table" => __PACKAGE__->table, }; }, { cascade_copy => 0, cascade_delete => 0 }, --- a/Koha/Schema/Result/Aqorder.pm +++ a/Koha/Schema/Result/Aqorder.pm @@ -900,10 +900,7 @@ __PACKAGE__->has_many( return { "$args->{foreign_alias}.record_id" => { -ident => "$args->{self_alias}.ordernumber" }, - - # TODO Add column additional_field_values.tablename to avoid subquery ? - "$args->{foreign_alias}.field_id" => - { -in => \'(SELECT id FROM additional_fields WHERE tablename = "aqorders")' }, + "$args->{foreign_alias}.record_table" => __PACKAGE__->table, }; }, { cascade_copy => 0, cascade_delete => 0 }, --- a/Koha/Schema/Result/Subscription.pm +++ a/Koha/Schema/Result/Subscription.pm @@ -577,9 +577,7 @@ __PACKAGE__->has_many( return { "$args->{foreign_alias}.record_id" => { -ident => "$args->{self_alias}.subscriptionid" }, - - "$args->{foreign_alias}.field_id" => - { -in => \'(SELECT id FROM additional_fields WHERE tablename = "subscription")' }, + "$args->{foreign_alias}.record_table" => __PACKAGE__->table, }; }, { cascade_copy => 0, cascade_delete => 0 }, --