Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

data_dictionary_builder.php unique constraint fix #9201

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions tools/exporters/data_dictionary_builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,13 @@
$instrumentParameterTypeCategoryIDs = [];
$instrumentParameterTypeIDs = [];


$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 +207,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 +268,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 +313,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
Loading