From 1638ab632c7a396e21f6e4ef6dcf6be1cb992d4e Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Wed, 7 Aug 2013 19:03:22 +0200 Subject: [PATCH] ido: Fix UQ violation in comments with host's hostcheck duplicated service comments refs #4380 --- lib/ido/servicedbobject.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/ido/servicedbobject.cpp b/lib/ido/servicedbobject.cpp index b31d90fec..30042bca9 100644 --- a/lib/ido/servicedbobject.cpp +++ b/lib/ido/servicedbobject.cpp @@ -330,16 +330,22 @@ void ServiceDbObject::AddCommentByType(DynamicObject::Ptr const& object, Diction if (object->GetType() == DynamicType::GetByName("Host")) { fields1->Set("comment_type", 2); fields1->Set("object_id", static_pointer_cast(object)); + /* this is obviously bullshit, but otherwise we would hit + * the unique constraint on the table for the same service + * comment. dynamically incremented/decremented numbers as + * unique constraint - wtf? + */ + fields1->Set("internal_comment_id", 0); } else if (object->GetType() == DynamicType::GetByName("Service")) { fields1->Set("comment_type", 1); fields1->Set("object_id", static_pointer_cast(object)); + fields1->Set("internal_comment_id", comment->Get("legacy_id")); } else { Log(LogDebug, "ido", "unknown object type for adding comment."); return; } - fields1->Set("comment_time", DbValue::FromTimestamp(Utility::GetTime())); - fields1->Set("internal_comment_id", comment->Get("legacy_id")); /* not sure if that's accurate? */ + fields1->Set("comment_time", DbValue::FromTimestamp(entry_time)); /* same as entry_time */ fields1->Set("author_name", comment->Get("author")); fields1->Set("comment_data", comment->Get("text")); fields1->Set("is_persistent", 1); -- 2.40.0