From 60f9493862900b7bb153e94bb17d8b04c490c53e Mon Sep 17 00:00:00 2001 From: Markus Frosch Date: Tue, 1 Mar 2016 00:22:28 +0100 Subject: [PATCH] Fix Host query for PostgreSQL refs #11110 --- application/tables/IcingaHostTable.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/application/tables/IcingaHostTable.php b/application/tables/IcingaHostTable.php index ff7b90b9..ec4e2869 100644 --- a/application/tables/IcingaHostTable.php +++ b/application/tables/IcingaHostTable.php @@ -13,13 +13,18 @@ class IcingaHostTable extends IcingaObjectTable public function getColumns() { + if ($this->connection()->getDbType() === 'pgsql') + $parents = "ARRAY_TO_STRING(ARRAY_AGG(ih.object_name), ', ')"; + else + $parents = "GROUP_CONCAT(ih.object_name ORDER BY hi.weight SEPARATOR ', ')"; + return array( 'id' => 'h.id', 'host' => 'h.object_name', 'object_type' => 'h.object_type', 'address' => 'h.address', 'zone' => 'z.object_name', - 'parents' => "GROUP_CONCAT(ih.object_name ORDER BY hi.weight SEPARATOR ', ')" + 'parents' => $parents, ); } @@ -55,7 +60,7 @@ class IcingaHostTable extends IcingaObjectTable array('ih' => 'icinga_host'), 'hi.parent_host_id = ih.id', array() - )->group('h.id') + )->group('h.id, z.object_name') ->order('h.object_name'); return $query;