Skip to content

Commit

Permalink
[tools] Fix data dict builder script(#4823)
Browse files Browse the repository at this point in the history
Replaced DELETE query using multi-JOIN by 2 query

Fixes #4615
  • Loading branch information
PapillonMcGill authored and driusan committed Jun 10, 2019
1 parent 9545c10 commit 50ef547
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions tools/exporters/data_dictionary_builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,22 @@
"Name"
);

// Single query to clear all old parameter_type data associated to instruments.
// 2 query to clear all old parameter_type data associated to instruments.
// This data will be rebuilt below and IDs will be preserved when possible using
// the data queried above
// the data queried above. Note, a single multi-join query fail with MySQL 5.7
$DB->run(
"DELETE parameter_type,
parameter_type_category_rel,
parameter_type_category
FROM parameter_type_category
JOIN parameter_type_category_rel USING(ParameterTypeCategoryID)
JOIN parameter_type USING(ParameterTypeID)
WHERE parameter_type_category.Type='Instrument';"
"DELETE parameter_type, parameter_type_category_rel
FROM parameter_type
JOIN parameter_type_category_rel USING (ParameterTypeID)
WHERE ParameterTypeCategoryID IN (
SELECT ParameterTypeCategoryID
FROM parameter_type_category
WHERE Type = 'Instrument'
);"
);

$DB->delete("parameter_type_category", array("Type" => "Instrument"));

print "Cleared data from BVL instruments\n";

print "Reading instruments\n";
Expand Down

0 comments on commit 50ef547

Please sign in to comment.