IdoQuery: Join hosts and services automatically if required for customvars

refs #9009
fixes #9426
This commit is contained in:
Johannes Meyer 2015-06-17 10:00:29 +02:00
parent 486fbd599b
commit 5c1cdbc1c8
1 changed files with 5 additions and 3 deletions

View File

@ -634,12 +634,14 @@ abstract class IdoQuery extends DbQuery
$this->customVars[$customvar] = $alias;
// TODO: extend if we allow queries with only hosts / only services
// ($leftcol s.host_object_id vs h.host_object_id
if ($this->hasJoinedVirtualTable('services')) {
$leftcol = 's.' . $type . '_object_id';
} elseif ($type === 'service') {
$this->requireVirtualTable('services');
$leftcol = 's.service_object_id';
} else {
$leftcol = 'h.' . $type . '_object_id';
$this->requireVirtualTable('hosts');
$leftcol = 'h.host_object_id';
}
$joinOn = sprintf(