summaryrefslogtreecommitdiff
path: root/src/components/policy/policy_external/src/sql_pt_representation.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/policy/policy_external/src/sql_pt_representation.cc')
-rw-r--r--src/components/policy/policy_external/src/sql_pt_representation.cc12
1 files changed, 12 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 5bee09773d..0436e82bbb 100644
--- a/src/components/policy/policy_external/src/sql_pt_representation.cc
+++ b/src/components/policy/policy_external/src/sql_pt_representation.cc
@@ -1575,6 +1575,18 @@ bool SQLPTRepresentation::SaveServiceEndpoints(
bool SQLPTRepresentation::SaveServiceEndpointProperties(
const policy_table::ServiceEndpointProperties& endpoint_properties) {
utils::dbms::SQLQuery query(db());
+
+ if (endpoint_properties.is_initialized() && endpoint_properties.empty()) {
+ bool delete_query_exec_result =
+ query.Exec(sql_pt::kDeleteEndpointProperties);
+
+ if (!delete_query_exec_result) {
+ SDL_LOG_WARN("Failed to delete endpoint properties from DB.");
+ return false;
+ }
+ return true;
+ }
+
if (!query.Prepare(sql_pt::kInsertEndpointVersion)) {
SDL_LOG_WARN(
"Incorrect insert of endpoint property to endpoint_properties.");