diff options
author | Mykola Korniichuk <mkorniichuk@luxoft.com> | 2019-08-29 17:26:07 +0300 |
---|---|---|
committer | Mykola Korniichuk <mkorniichuk@luxoft.com> | 2019-09-02 14:00:56 +0300 |
commit | 8e15a699029f3d6e2e18d45d117a7d4e814a3c3c (patch) | |
tree | b72b06668abd94e95ea45b7d86a65eb8cc9563a5 | |
parent | e7b5c75c704f6cd577f0857e4cbe17cf6ec160fa (diff) | |
download | sdl_core-8e15a699029f3d6e2e18d45d117a7d4e814a3c3c.tar.gz |
Add check for already stored vehicle data item paramsfix/PTU_trigger_on_ignition_cycles_doesnt_work_properly
-rw-r--r-- | src/components/policy/policy_external/src/sql_pt_representation.cc | 8 | ||||
-rw-r--r-- | src/components/policy/policy_regular/src/sql_pt_representation.cc | 8 |
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; } } |