From 7f4c044a9dad468b91e3fc51385737d5948deaee Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 2 Apr 2020 15:46:12 +0200 Subject: [PATCH] Bug 25043: Play with union --- Koha/Schema.pm | 5 ++++- Koha/Schema/ResultSet.pm | 5 +++++ test.pl | 10 ++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 Koha/Schema/ResultSet.pm create mode 100644 test.pl diff --git a/Koha/Schema.pm b/Koha/Schema.pm index cffc631d5e..f401cbb58e 100644 --- a/Koha/Schema.pm +++ b/Koha/Schema.pm @@ -9,7 +9,10 @@ use warnings; use base 'DBIx::Class::Schema'; -__PACKAGE__->load_namespaces; + +__PACKAGE__->load_namespaces( + default_resultset_class => 'ResultSet', +); # Created by DBIx::Class::Schema::Loader v0.07025 @ 2013-10-14 20:56:21 diff --git a/Koha/Schema/ResultSet.pm b/Koha/Schema/ResultSet.pm new file mode 100644 index 0000000000..830a677b7d --- /dev/null +++ b/Koha/Schema/ResultSet.pm @@ -0,0 +1,5 @@ +package Koha::Schema::ResultSet; +use strict; +use warnings; +use parent 'DBIx::Class::ResultSet'; +__PACKAGE__->load_components('Helper::ResultSet::SetOperations'); diff --git a/test.pl b/test.pl new file mode 100644 index 0000000000..af249eb465 --- /dev/null +++ b/test.pl @@ -0,0 +1,10 @@ +use Modern::Perl; +use Koha::Database; +my $borrowernumber = 5; +my $holds = Koha::Database->new()->schema()->resultset('Reserve')->search({ borrowernumber => $borrowernumber }); +my $old_holds = Koha::Database->new()->schema()->resultset('OldReserve')->search({ borrowernumber => $borrowernumber }); + +$_->result_class('DBIx::Class::ResultClass::HashRefInflator') + for ($holds, $old_holds); + +say $holds->union($old_holds)->count; -- 2.20.1