Bug 21606: [sql_modes] Fix matching rules insert
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 18 Oct 2018 22:27:21 +0000 (19:27 -0300)
committerNick Clemens <nick@bywatersolutions.com>
Fri, 2 Nov 2018 10:33:08 +0000 (10:33 +0000)
Fix:
Incorrect integer value: '' for column 'offset'
Incorrect integer value: '' for column 'score'

Test plan:
Add/edit matching rules

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
C4/Matcher.pm

index 5a62c05..d19dd64 100644 (file)
@@ -331,7 +331,7 @@ sub _store_matchpoint {
     my $matcher_id = $self->{'id'};
     $sth = $dbh->prepare_cached("INSERT INTO matchpoints (matcher_id, search_index, score)
                                  VALUES (?, ?, ?)");
-    $sth->execute($matcher_id, $matchpoint->{'index'}, $matchpoint->{'score'});
+    $sth->execute($matcher_id, $matchpoint->{'index'}, $matchpoint->{'score'}||0);
     my $matchpoint_id = $dbh->{'mysql_insertid'};
     my $seqnum = 0;
     foreach my $component (@{ $matchpoint->{'components'} }) {
@@ -343,7 +343,7 @@ sub _store_matchpoint {
         $sth->bind_param(2, $seqnum);
         $sth->bind_param(3, $component->{'tag'});
         $sth->bind_param(4, join "", sort keys %{ $component->{'subfields'} });
-        $sth->bind_param(5, $component->{'offset'});
+        $sth->bind_param(5, $component->{'offset'}||0);
         $sth->bind_param(6, $component->{'length'});
         $sth->execute();
         my $matchpoint_component_id = $dbh->{'mysql_insertid'};