Bugzilla – Attachment 103812 Details for
Bug 25296
Add a way to force an empty Koha::Objects resultset
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 25296: Add a way to force an empty Koha::Objects resultset
Bug-25296-Add-a-way-to-force-an-empty-KohaObjects-.patch (text/plain), 1.38 KB, created by
Tomás Cohen Arazi (tcohen)
on 2020-04-27 21:37:15 UTC
(
hide
)
Description:
Bug 25296: Add a way to force an empty Koha::Objects resultset
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2020-04-27 21:37:15 UTC
Size:
1.38 KB
patch
obsolete
>From c2d856fe0e09c080fea0f90faa0947244140f79b Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 27 Apr 2020 18:33:05 -0300 >Subject: [PATCH] Bug 25296: Add a way to force an empty Koha::Objects > resultset > >This patch adds a new ->empty method to Koha::Objects, that can be used >to make the underlying DBIC resultset empty. This way, we can have >consistency in our method's return values without the need to build >a query that we know in advance that will be empty. No need to hit the >DB at all. > >To test: >1. Apply this patches >2. Notice the tests cover what is expected >3. Run: > $ kshell > k$ prove t/db_dependent/Koha/Objects.t >=> SUCCESS: Tests pass! Yay! >4. Sign off :-D > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > Koha/Objects.pm | 16 ++++++++++++++++ > 1 file changed, 16 insertions(+) > >diff --git a/Koha/Objects.pm b/Koha/Objects.pm >index 9184a235a8..bc82ee4e15 100644 >--- a/Koha/Objects.pm >+++ b/Koha/Objects.pm >@@ -237,7 +237,23 @@ sub last { > return $object; > } > >+=head3 empty > >+ my $empty_rs = Koha::Objects->new->empty; >+ >+Sets the resultset empty. This is handy for consistency on method returns >+(e.g. if we know in advance we won't have results but want to keep returning >+an iterator). >+ >+=cut >+ >+sub empty { >+ my ($self) = @_; >+ >+ $self->_resultset()->set_cache([]); >+ >+ return $self; >+} > > =head3 Koha::Objects->reset(); > >-- >2.26.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 25296
:
103811
|
103812
|
103860
|
103861
|
103928
|
103929
|
103934
|
103935
|
103936
|
103937