Bugzilla – Attachment 74555 Details for
Bug 20621
Add ability for Koha::Object objects to update themselves with database generated value automatically
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20621: Add ability for Koha::Object objects to update themselves with database generated value automatically
Bug-20621-Add-ability-for-KohaObject-objects-to-up.patch (text/plain), 1.60 KB, created by
Kyle M Hall (khall)
on 2018-04-19 13:28:24 UTC
(
hide
)
Description:
Bug 20621: Add ability for Koha::Object objects to update themselves with database generated value automatically
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2018-04-19 13:28:24 UTC
Size:
1.60 KB
patch
obsolete
>From 550a0f8213d521044a5d688a7d0a5f038b55aa39 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatetsolutions.com> >Date: Thu, 19 Apr 2018 09:27:35 -0400 >Subject: [PATCH] Bug 20621: Add ability for Koha::Object objects to update > themselves with database generated value automatically > >Koha objects should, on store() update themselves from the db if the database creates any of the columns. That way we don't have to call discard_changes() manually. > >See https://wiki.koha-community.org/wiki/Koha_Objects#store_doesn.27t_return_the_DB_object for details. >--- > Koha/Object.pm | 15 ++++++++++++++- > 1 file changed, 14 insertions(+), 1 deletion(-) > >diff --git a/Koha/Object.pm b/Koha/Object.pm >index 1f54273493..dbb645b2ad 100644 >--- a/Koha/Object.pm >+++ b/Koha/Object.pm >@@ -121,7 +121,9 @@ sub store { > my ($self) = @_; > > try { >- return $self->_result()->update_or_insert() ? $self : undef; >+ my $object = $self->_result()->update_or_insert() ? $self : undef; >+ $object->discard_changes if $object->_has_derived_columns && defined wantarray; >+ return $object; > } > catch { > # Catch problems and raise relevant exceptions >@@ -401,6 +403,17 @@ sub AUTOLOAD { > return $r; > } > >+=head3 _has_derived_columns >+ >+This method is a flag that tells us if an object has derived columns generated by the database. >+If the object does, this method should return true. If not, it can be left out. >+ >+=cut >+ >+sub _has_derived_columns { >+ return 0; >+} >+ > =head3 _type > > This method must be defined in the child class. The value is the name of the DBIC resultset. >-- >2.15.1 (Apple Git-101)
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 20621
: 74555