Bug 24593: (follow-up) fix sql statements
authorBernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Wed, 4 Mar 2020 14:31:29 +0000 (11:31 -0300)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Mon, 9 Mar 2020 13:54:40 +0000 (13:54 +0000)
Original inserted values depends on the order of insertion.
This patch rewrites the sql statements to make them order
independent

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

installer/data/mysql/en/marcflavour/marc21/optional/marc21_default_matching_rules.yml

index 7dd48f2..8d6492c 100644 (file)
@@ -48,22 +48,23 @@ tables:
           threshold: 1000
 
 sql_statements:
-  - "INSERT INTO matchpoints (matcher_id, search_index, score) SELECT MAX(matcher_id), 'isbn', 1000 FROM marc_matchers;"
-  - "INSERT INTO matcher_matchpoints SELECT MAX(matcher_id), MAX(matchpoint_id) FROM matchpoints;"
-  - "INSERT INTO matchpoint_components (matchpoint_id, sequence, tag, subfields) SELECT MAX(matchpoint_id), 1, '020', 'a' FROM matchpoints;"
+  - "INSERT INTO matchpoints (matcher_id, search_index, score) SELECT matcher_id, 'isbn', 1000 FROM marc_matchers WHERE code = 'ISBN';"
+  - "INSERT INTO matcher_matchpoints SELECT matcher_id, matchpoint_id FROM matchpoints WHERE search_index = 'isbn';"
+  - "INSERT INTO matchpoint_components (matchpoint_id, sequence, tag, subfields)
+     SELECT matchpoint_id, 1, '020', 'a' FROM matchpoints WHERE search_index = 'isbn';"
   - "INSERT INTO matchpoint_component_norms (matchpoint_component_id, sequence, norm_routine)
-     SELECT MAX(matchpoint_component_id), 1, 'ISBN' FROM matchpoint_components;"
+     SELECT matchpoint_component_id, 1, 'ISBN' FROM matchpoint_components WHERE tag = '020';"
 
-  - "INSERT INTO matchpoints (matcher_id, search_index, score) SELECT MAX(matcher_id), 'issn', 1000 FROM marc_matchers;"
-  - "INSERT INTO matcher_matchpoints SELECT MAX(matcher_id), MAX(matchpoint_id) FROM matchpoints;"
+  - "INSERT INTO matchpoints (matcher_id, search_index, score) SELECT matcher_id, 'issn', 1000 FROM marc_matchers WHERE code = 'ISSN';"
+  - "INSERT INTO matcher_matchpoints SELECT matcher_id, matchpoint_id FROM matchpoints WHERE search_index = 'issn';"
   - "INSERT INTO matchpoint_components (matchpoint_id, sequence, tag, subfields)
-     SELECT MAX(matchpoint_id), 1, '022', 'a' FROM matchpoints;"
+     SELECT matchpoint_id, 1, '022', 'a' FROM matchpoints WHERE search_index = 'issn';"
   - "INSERT INTO matchpoint_component_norms (matchpoint_component_id, sequence, norm_routine)
-     SELECT MAX(matchpoint_component_id), 1, 'ISSN' FROM matchpoint_components;"
+     SELECT matchpoint_component_id, 1, 'ISSN' FROM matchpoint_components WHERE tag = '022';"
 
-  - "INSERT INTO matchpoints (matcher_id, search_index, score) SELECT MAX(matcher_id), 'local-number', 1000 FROM marc_matchers;"
-  - "INSERT INTO matcher_matchpoints SELECT MAX(matcher_id), MAX(matchpoint_id) FROM matchpoints;"
+  - "INSERT INTO matchpoints (matcher_id, search_index, score) SELECT matcher_id, 'local-number', 1000 FROM marc_matchers WHERE code = 'KohaBiblio';"
+  - "INSERT INTO matcher_matchpoints SELECT matcher_id, matchpoint_id FROM matchpoints WHERE search_index = 'local-number';"
   - "INSERT INTO matchpoint_components (matchpoint_id, sequence, tag, subfields)
-     SELECT MAX(matchpoint_id), 1, '999', 'c' FROM matchpoints;"
+     SELECT matchpoint_id, 1, '999', 'c' FROM matchpoints WHERE search_index = 'local-number';"
   - "INSERT INTO matchpoint_component_norms (matchpoint_component_id, sequence, norm_routine)
-     SELECT MAX(matchpoint_component_id), 1, 'Biblionumber' FROM matchpoint_components;"
+     SELECT matchpoint_component_id, 1, 'Biblionumber' FROM matchpoint_components WHERE tag = '999';"