Skip to content

Commit

Permalink
data_dictionary_builder.php unique constraint fix
Browse files Browse the repository at this point in the history
  • Loading branch information
laemtl committed Apr 11, 2024
1 parent d3e7bf2 commit 4591517
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions tools/exporters/data_dictionary_builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 = "";
Expand Down Expand Up @@ -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 = "";
Expand Down

0 comments on commit 4591517

Please # to comment.