From c1e41d4d7255b96a985d2ff8504a93f5fead4b7d Mon Sep 17 00:00:00 2001 From: Blou Date: Tue, 6 Sep 2016 12:00:01 -0400 Subject: [PATCH] Bug 17260 - updatedatabase.pl fails on invalid entries in ENUM and BOOLEAN columns The loading of file admin/searchengine/elasticsearch/mappings.yaml specifies 'type' as empty, which fails with Mysql 5.7+ which is more stringent. Also, forcing an empty value into a boolean also fails. Both issues arise when updatedatabase.pl hit 3.23.00.050. NOTE: both issues could also be resolved by actually setting values in the load file. This doesn't make this solution incorrect, though. To Test/reproduce: -1) Happens with Mysql 5.7.4. Maybe earlier, but certainly at that point. 0) Find a database on 3.22 or earlier, save it. 1) Set your code base to master) 2) run updatedatabase.pl 3) See the errors on 3.23.00.050 4) Apply the patch 5) Reload the 3.22 db. 6) succeed with updatedatabase.pl --- installer/data/mysql/updatedatabase.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 05045cd..f348cfe 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -12280,7 +12280,7 @@ if ( CheckVersion($DBversion) ) { `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(255) NOT NULL COMMENT 'the name of the field as it will be stored in the search engine', `label` varchar(255) NOT NULL COMMENT 'the human readable name of the field, for display', - `type` ENUM('string', 'date', 'number', 'boolean', 'sum') NOT NULL COMMENT 'what type of data this holds, relevant when storing it in the search engine', + `type` ENUM('', 'string', 'date', 'number', 'boolean', 'sum') NOT NULL COMMENT 'what type of data this holds, relevant when storing it in the search engine', PRIMARY KEY (`id`), UNIQUE KEY (`name`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci @@ -12337,7 +12337,7 @@ while ( my ( $index_name, $fields ) = each %$indexes ) { my $search_field = Koha::SearchFields->find_or_create({ name => $field_name, label => $field_label, type => $field_type }, { key => 'name' }); for my $mapping ( @$mappings ) { my $marc_field = Koha::SearchMarcMaps->find_or_create({ index_name => $index_name, marc_type => $mapping->{marc_type}, marc_field => $mapping->{marc_field} }); - $search_field->add_to_search_marc_maps($marc_field, { facet => $mapping->{facet}, suggestible => $mapping->{suggestible}, sort => $mapping->{sort} } ); + $search_field->add_to_search_marc_maps($marc_field, { facet => $mapping->{facet} || 0, suggestible => $mapping->{suggestible} || 0, sort => $mapping->{sort} } ); } } } -- 2.1.0