summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/components/policy/policy_external/src/sql_pt_representation.cc8
-rw-r--r--src/components/policy/policy_regular/src/sql_pt_representation.cc8
2 files changed, 16 insertions, 0 deletions
diff --git a/src/components/policy/policy_external/src/sql_pt_representation.cc b/src/components/policy/policy_external/src/sql_pt_representation.cc
index 7874abc4ee..d8f137a52c 100644
--- a/src/components/policy/policy_external/src/sql_pt_representation.cc
+++ b/src/components/policy/policy_external/src/sql_pt_representation.cc
@@ -2660,11 +2660,18 @@ bool SQLPTRepresentation::InsertVehicleDataItem(
}
if (vehicle_data_item.params->is_initialized()) {
+ std::map<std::string, std::string> stored_vehicle_data_item_params;
for (const auto& param : *(vehicle_data_item.params)) {
if (!InsertVehicleDataItem(param)) {
return false;
}
+ if (stored_vehicle_data_item_params.end() !=
+ stored_vehicle_data_item_params.find(param.name)) {
+ LOG4CXX_DEBUG(logger_, "Parameter already stored.");
+ continue;
+ }
+
if (!query.Prepare(sql_pt::kInsertVehicleDataItemParams)) {
LOG4CXX_ERROR(logger_,
"Incorrent select statement of vehicle data item. "
@@ -2685,6 +2692,7 @@ bool SQLPTRepresentation::InsertVehicleDataItem(
<< ". Error: " << query.LastError().text());
return false;
}
+ stored_vehicle_data_item_params[param.name] = param.key;
}
}
diff --git a/src/components/policy/policy_regular/src/sql_pt_representation.cc b/src/components/policy/policy_regular/src/sql_pt_representation.cc
index ce0527600a..60a4ef6021 100644
--- a/src/components/policy/policy_regular/src/sql_pt_representation.cc
+++ b/src/components/policy/policy_regular/src/sql_pt_representation.cc
@@ -2687,11 +2687,18 @@ bool SQLPTRepresentation::InsertVehicleDataItem(
}
if (vehicle_data_item.params->is_initialized()) {
+ std::map<std::string, std::string> stored_vehicle_data_item_params;
for (const auto& param : *(vehicle_data_item.params)) {
if (!InsertVehicleDataItem(param)) {
return false;
}
+ if (stored_vehicle_data_item_params.end() !=
+ stored_vehicle_data_item_params.find(param.name)) {
+ LOG4CXX_DEBUG(logger_, "Parameter already stored.");
+ continue;
+ };
+
if (!query.Prepare(sql_pt::kInsertVehicleDataItemParams)) {
LOG4CXX_ERROR(logger_,
"Incorrent select statement of vehicle data item. "
@@ -2712,6 +2719,7 @@ bool SQLPTRepresentation::InsertVehicleDataItem(
<< ". Error: " << query.LastError().text());
return false;
}
+ stored_vehicle_data_item_params[param.name] = param.key;
}
}