diff options
author | Jacob Keeler <jacob.keeler@livioradio.com> | 2019-09-03 16:40:41 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-03 16:40:41 -0400 |
commit | bc8288d775d8d088c203ba9500ed6fcb9fab95b4 (patch) | |
tree | 93bf05d85cf0581a200a4718c06a3bf6f69a8431 | |
parent | f069a231347d739ca3b1f85599262e975144ccb4 (diff) | |
parent | 8e15a699029f3d6e2e18d45d117a7d4e814a3c3c (diff) | |
download | sdl_core-bc8288d775d8d088c203ba9500ed6fcb9fab95b4.tar.gz |
Merge pull request #3005 from smartdevicelink/fix/PTU_trigger_on_ignition_cycles_doesnt_work_properly
Add check for already stored vehicle data item params
-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; } } |