From 9c383aa286fee5a29c6f084873f2eb6644bad64f Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 23 Mar 2020 17:21:24 +0100 Subject: [PATCH] Bug 23463: (follow-up 3) Fix timestamp default value This is the only situation I found where: * t/db_dependent/Koha/Item.t is passing * t/db_dependent/Koha/Object.t is passing * MySQL 8 is happy (and not fail with "Column 'timestamp' cannot be null"), which is certainly what I missed in the previous follow-up About the change to Object.t: the next store was called without the generated timestamp, so it is needed to call discard_changes. Signed-off-by: Martin Renvoize --- Koha/Item.pm | 2 -- Koha/Object.pm | 2 +- t/db_dependent/Koha/Object.t | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Koha/Item.pm b/Koha/Item.pm index af86f45378..48dc73bf5c 100644 --- a/Koha/Item.pm +++ b/Koha/Item.pm @@ -156,8 +156,6 @@ sub store { $self->permanent_location( $self->location ); } - $self->timestamp(undef) if $self->timestamp; # Maybe move this to Koha::Object->store? - C4::Biblio::ModZebra( $self->biblionumber, "specialUpdate", "biblioserver" ); $self->_after_item_action_hooks({ action => 'modify' }); diff --git a/Koha/Object.pm b/Koha/Object.pm index 6029217e0f..e56f4b18f4 100644 --- a/Koha/Object.pm +++ b/Koha/Object.pm @@ -155,7 +155,7 @@ sub store { && $columns_info->{$col}->{datetime_undef_if_invalid} ) { # timestamp - # $self->_result()->set_column($col => $columns_info->{$col}->{default_value}); + $self->_result()->set_column($col => $columns_info->{$col}->{default_value}); } } } diff --git a/t/db_dependent/Koha/Object.t b/t/db_dependent/Koha/Object.t index 0918785375..2d4413486d 100755 --- a/t/db_dependent/Koha/Object.t +++ b/t/db_dependent/Koha/Object.t @@ -58,7 +58,7 @@ subtest 'is_changed / make_column_dirty' => sub { $object->categorycode( $categorycode ); $object->branchcode( $branchcode ); $object->surname("Test Surname"); - $object->store(); + $object->store->discard_changes; is( $object->is_changed(), 0, "Object is unchanged" ); $object->surname("Test Surname"); is( $object->is_changed(), 0, "Object is still unchanged" ); -- 2.39.5