From f65d0a8bf9c38369e9091f54e07dd88db8082e6d Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 6 Apr 2022 00:05:31 +0200 Subject: [PATCH] Group summaries: Do not use NULL for name columns Previously, all name columns in the UNION queries yield NULL except for the Hostgroup or Servicegroup query. In PostgreSQL, this leads to separate result sets because all SELECT columns must appear in the GROUP BY clause, which also includes name columns. --- library/Icingadb/Model/Hostgroupsummary.php | 8 ++++---- library/Icingadb/Model/ServicegroupSummary.php | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/library/Icingadb/Model/Hostgroupsummary.php b/library/Icingadb/Model/Hostgroupsummary.php index 68c4a3e6b..270983127 100644 --- a/library/Icingadb/Model/Hostgroupsummary.php +++ b/library/Icingadb/Model/Hostgroupsummary.php @@ -107,8 +107,8 @@ public function getUnions() ], [ 'hostgroup_id' => 'hostgroup.id', - 'hostgroup_name' => new Expression('NULL'), - 'hostgroup_display_name' => new Expression('NULL'), + 'hostgroup_name' => 'hostgroup.name', + 'hostgroup_display_name' => 'hostgroup.display_name', 'host_id' => 'host.id', 'host_state' => 'state.soft_state', 'host_handled' => 'state.is_handled', @@ -126,8 +126,8 @@ public function getUnions() ], [ 'hostgroup_id' => 'hostgroup.id', - 'hostgroup_name' => new Expression('NULL'), - 'hostgroup_display_name' => new Expression('NULL'), + 'hostgroup_name' => 'hostgroup.name', + 'hostgroup_display_name' => 'hostgroup.display_name', 'host_id' => new Expression('NULL'), 'host_state' => new Expression('NULL'), 'host_handled' => new Expression('NULL'), diff --git a/library/Icingadb/Model/ServicegroupSummary.php b/library/Icingadb/Model/ServicegroupSummary.php index 1b5232ce3..5681f7995 100644 --- a/library/Icingadb/Model/ServicegroupSummary.php +++ b/library/Icingadb/Model/ServicegroupSummary.php @@ -83,8 +83,8 @@ public function getUnions() ], [ 'servicegroup_id' => 'servicegroup.id', - 'servicegroup_name' => new Expression('NULL'), - 'servicegroup_display_name' => new Expression('NULL'), + 'servicegroup_name' => 'servicegroup.name', + 'servicegroup_display_name' => 'servicegroup.display_name', 'service_id' => 'service.id', 'service_state' => 'state.soft_state', 'service_handled' => 'state.is_handled',