Bug 27021: Make chaining ->empty always return an empty resultset

This patch borrows the implementation Martin did on bug 27002, to
woraround this issue, and implements it properly on the
Koha::Objects->empty method.

To test:
1. Apply the regression tests patch
2. Run:
   $ kshell
  k$ prove t/db_dependent/Koha/Objects.t
=> FAIL: Tests fail! The resultset should be empty and it isn't!
3. Apply this patch
4. Repeat 2
=> SUCCESS: Tests pass!
5. Sign off!

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
(cherry picked from commit 55835ccfaf)

Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
This commit is contained in:
Tomas Cohen Arazi 2020-11-13 15:54:32 -03:00 committed by Andrew Fuerste-Henry
parent f3242ccc7c
commit 1e7d04a608
1 changed files with 1 additions and 0 deletions

View File

@ -336,6 +336,7 @@ sub empty {
class => $self
) unless ref $self;
$self = $self->search(\'0 = 1');
$self->_resultset()->set_cache([]);
return $self;