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 <wizzyrea@gmail.com>

JD: Edit after SO, remove unecessary changes (not related to this bug)

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
(cherry picked from commit 2329d2ea83)
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
Jonathan Druart 2019-05-14 12:06:24 -05:00 committed by Martin Renvoize
parent b1c6a74368
commit 967f92bdd2
No known key found for this signature in database
GPG Key ID: 422B469130441A0F
1 changed files with 4 additions and 4 deletions

View File

@ -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 $@;