DB IDO: Ensure that delete queries for comments/downtimes are matching the index

fixes #11993
This commit is contained in:
Michael Friedrich 2016-06-20 17:38:01 +02:00
parent f10289aa71
commit 409a385590
1 changed files with 6 additions and 3 deletions

View File

@ -403,19 +403,21 @@ void DbEvents::RemoveCommentInternal(std::vector<DbQuery>& queries, const Commen
{
Checkable::Ptr checkable = comment->GetCheckable();
unsigned long entry_time = static_cast<long>(comment->GetEntryTime());
/* Status */
DbQuery query1;
query1.Table = "comments";
query1.Type = DbQueryDelete;
query1.Category = DbCatComment;
query1.WhereCriteria = new Dictionary();
query1.WhereCriteria->Set("object_id", checkable);
query1.WhereCriteria->Set("internal_comment_id", comment->GetLegacyId());
query1.WhereCriteria->Set("object_id", checkable);
query1.WhereCriteria->Set("comment_time", DbValue::FromTimestamp(entry_time));
query1.WhereCriteria->Set("instance_id", 0); /* DbConnection class fills in real ID */
queries.push_back(query1);
/* History - update deletion time for service/host */
unsigned long entry_time = static_cast<long>(comment->GetEntryTime());
double now = Utility::GetTime();
std::pair<unsigned long, unsigned long> time_bag = CompatUtility::ConvertTimestamp(now);
@ -582,6 +584,7 @@ void DbEvents::RemoveDowntimeInternal(std::vector<DbQuery>& queries, const Downt
query1.WhereCriteria = new Dictionary();
query1.WhereCriteria->Set("object_id", checkable);
query1.WhereCriteria->Set("internal_downtime_id", downtime->GetLegacyId());
query1.WhereCriteria->Set("entry_time", DbValue::FromTimestamp(downtime->GetEntryTime()));
query1.WhereCriteria->Set("instance_id", 0); /* DbConnection class fills in real ID */
queries.push_back(query1);