From 459151781aad88e5ccf4bbaca28b06d5c8087227 Mon Sep 17 00:00:00 2001 From: Laetitia Fesselier Date: Thu, 11 Apr 2024 13:39:15 -0400 Subject: [PATCH] data_dictionary_builder.php unique constraint fix --- tools/exporters/data_dictionary_builder.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/tools/exporters/data_dictionary_builder.php b/tools/exporters/data_dictionary_builder.php index 8ffaab279f2..b9ec7b6483b 100755 --- a/tools/exporters/data_dictionary_builder.php +++ b/tools/exporters/data_dictionary_builder.php @@ -53,9 +53,9 @@ $parameter_types = $DB->pselectColWithIndexKey( - "Select Name, ParameterTypeID from parameter_type", + "Select CONCAT(`Name`, '-', `SourceFrom`) AS paramkey, ParameterTypeID from parameter_type", [], - "Name" + "paramkey" ); // 2 query to clear all old parameter_type data associated to instruments. @@ -205,11 +205,12 @@ "Queryable" => "1", ]; + $key = "$Name-$testname"; // Check if the same element existed in the parameter_type table // before deleting the data. - if (array_key_exists($Name, $parameter_types)) { + if (array_key_exists($key, $parameter_types)) { //If element existed, reuse the same id - $ParameterTypeID = $parameter_types[$Name]; + $ParameterTypeID = $parameter_types[$key]; $query_params["ParameterTypeID"] = $ParameterTypeID; } else { //If it's new set it to empty string @@ -265,8 +266,9 @@ "Queryable" => "1", ]; - if (array_key_exists($Name, $parameter_types)) { - $ParameterTypeID = $parameter_types[$Name]; + $key = "$Name-$testname"; + if (array_key_exists($key, $parameter_types)) { + $ParameterTypeID = $parameter_types[$key]; $query_params["ParameterTypeID"] = $ParameterTypeID; } else { $ParameterTypeID = ""; @@ -309,8 +311,9 @@ "Queryable" => "1", ]; - if (array_key_exists($Name, $parameter_types)) { - $ParameterTypeID = $parameter_types[$Name]; + $key = "$Name-$testname"; + if (array_key_exists($key, $parameter_types)) { + $ParameterTypeID = $parameter_types[$key]; $query_params["ParameterTypeID"] = $ParameterTypeID; } else { $ParameterTypeID = "";