Skip to content

Commit

Permalink
Model: Add left join to relations
Browse files Browse the repository at this point in the history
RedundancyGroup -> DependencyEdge
DependencyEdge -> DependencyNode

The DependecyNodeSummary requires left joins to summarise all available rows,
while the redundancy group joins DependencyEdge and DependencyNode as inner joins, which leads to false positives.
  • Loading branch information
sukhwinder33445 committed Oct 9, 2024
1 parent 9506986 commit a327201
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions library/Icingadb/Model/DependencyEdge.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,11 @@ public function createRelations(Relations $relations): void

// "from" and "to" are only necessary for sub-query filters.
$relations->belongsTo('from', DependencyNode::class)
->setCandidateKey('from_node_id');
->setCandidateKey('from_node_id')
->setJoinType('LEFT');

$relations->belongsTo('to', DependencyNode::class)
->setCandidateKey('to_node_id');
->setCandidateKey('to_node_id')
->setJoinType('LEFT');
}
}
7 changes: 5 additions & 2 deletions library/Icingadb/Model/RedundancyGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,13 @@ public function createRelations(Relations $relations): void
$relations->belongsToMany('from', DependencyEdge::class)
->setTargetCandidateKey('from_node_id')
->setTargetForeignKey('id')
->through(DependencyNode::class);
->through(DependencyNode::class)
->setJoinType('LEFT');

$relations->belongsToMany('to', DependencyEdge::class)
->setTargetCandidateKey('to_node_id')
->setTargetForeignKey('id')
->through(DependencyNode::class);
->through(DependencyNode::class)
->setJoinType('LEFT');
}
}

0 comments on commit a327201

Please sign in to comment.