Bugzilla – Attachment 173507 Details for
Bug 38273
Koha::Object->discard_changes should return the Koha::Object for chaining
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 38273: Make Koha::Object->discard_changes chainable
Bug-38273-Make-KohaObject-discardchanges-chainable.patch (text/plain), 2.41 KB, created by
Jonathan Druart
on 2024-10-28 10:49:34 UTC
(
hide
)
Description:
Bug 38273: Make Koha::Object->discard_changes chainable
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2024-10-28 10:49:34 UTC
Size:
2.41 KB
patch
obsolete
>From 286405aefe9d9bc5a0701c03aa9007fd31c3d8f4 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 28 Oct 2024 11:49:13 +0100 >Subject: [PATCH] Bug 38273: Make Koha::Object->discard_changes chainable > >--- > Koha/Object.pm | 15 ++++++++++++++- > t/db_dependent/Koha/Object.t | 13 ++++++++++++- > 2 files changed, 26 insertions(+), 2 deletions(-) > >diff --git a/Koha/Object.pm b/Koha/Object.pm >index 8139acfaa98..cda441effb5 100644 >--- a/Koha/Object.pm >+++ b/Koha/Object.pm >@@ -218,6 +218,19 @@ sub store { > } > } > >+ >+=head3 discard_changes >+ >+Refetch the row from the DB >+ >+=cut >+ >+sub discard_changes { >+ my ($self) = @_; >+ my $object_class = Koha::Object::_get_object_class( $self->_result->result_class ); >+ return $object_class->_new_from_dbic( $self->_result->discard_changes ); >+} >+ > =head3 $object->update(); > > A shortcut for set + store in one call. >@@ -1020,7 +1033,7 @@ sub AUTOLOAD { > return $accessor->( $self, @_ ); > } > >- my @known_methods = qw( is_changed id in_storage get_column discard_changes make_column_dirty ); >+ my @known_methods = qw( is_changed id in_storage get_column make_column_dirty ); > > Koha::Exceptions::Object::MethodNotCoveredByTests->throw( > error => sprintf("The method %s->%s is not covered by tests!", ref($self), $method), >diff --git a/t/db_dependent/Koha/Object.t b/t/db_dependent/Koha/Object.t >index 9f751c80b3b..0cb41f19320 100755 >--- a/t/db_dependent/Koha/Object.t >+++ b/t/db_dependent/Koha/Object.t >@@ -153,7 +153,7 @@ subtest 'get_column' => sub { > }; > > subtest 'discard_changes' => sub { >- plan tests => 1; >+ plan tests => 3; > > $schema->storage->txn_begin; > >@@ -166,6 +166,17 @@ subtest 'discard_changes' => sub { > dt_from_string->truncate( to => 'day' ), > 'discard_changes should refresh the object' > ); >+ my $cardnumber = $patron->cardnumber; >+ my $categorycode = $patron->categorycode; >+ my $branchcode = $patron->branchcode; >+ $patron->delete; >+ >+ $patron = >+ Koha::Patron->new( { cardnumber => $cardnumber, categorycode => $categorycode, branchcode => $branchcode } ) >+ ->store->discard_changes; >+ >+ is( ref($patron), 'Koha::Patron', 'discard_changes should return a Koha::Object object' ); >+ isnt( $patron->updated_on, undef, 'discard_changes should have fetched the row from the DB' ); > > $schema->storage->txn_rollback; > }; >-- >2.34.1
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 38273
:
173507
|
173528
|
173529
|
173538
|
173539
|
173705