From 967f92bdd28edcfd3224783cb652178ec7c09ad2 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 14 May 2019 12:06:24 -0500 Subject: [PATCH] Bug 22907: Fix new suggestion with strict sql modes With sql_strict_modes turned on, if you try to create a new suggestion you will get: Incorrect integer value: '' for column '$INT_COLUMN' at row 1 Test plan: Turn on strict_sql_modes, create a new suggestion, then edit it. Signed-off-by: Liz Rea JD: Edit after SO, remove unecessary changes (not related to this bug) Signed-off-by: Marcel de Rooy Signed-off-by: Nick Clemens (cherry picked from commit 2329d2ea8393e133bf689eb2d311fb0bcc99640f) Signed-off-by: Martin Renvoize --- C4/Suggestions.pm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/C4/Suggestions.pm b/C4/Suggestions.pm index 42be6f3add..35d72ea0fc 100644 --- a/C4/Suggestions.pm +++ b/C4/Suggestions.pm @@ -453,8 +453,8 @@ sub NewSuggestion { $suggestion->{suggesteddate} = dt_from_string unless $suggestion->{suggesteddate}; - my $rs = Koha::Database->new->schema->resultset('Suggestion'); - return $rs->create($suggestion)->id; + my $suggestion_object = Koha::Suggestion->new( $suggestion )->store; + return $suggestion_object->suggestionid; } =head2 ModSuggestion @@ -491,9 +491,9 @@ sub ModSuggestion { or $suggestion->{$field} eq '' ); } - my $rs = Koha::Database->new->schema->resultset('Suggestion')->find($suggestion->{suggestionid}); + my $suggestion_object = Koha::Suggestions->find( $suggestion->{suggestionid} ); eval { # FIXME Must raise an exception instead - $rs->update($suggestion); + $suggestion_object->set($suggestion)->store; }; return 0 if $@; -- 2.39.5