mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-09-25 18:59:05 +02:00
IcingaObjectResolver: support PostgreSQL
This commit is contained in:
parent
421f47d08d
commit
babae3e068
@ -178,18 +178,20 @@ class IcingaObjectResolver
|
|||||||
*/
|
*/
|
||||||
protected function fetchInheritancePaths($baseTable, $relColumn)
|
protected function fetchInheritancePaths($baseTable, $relColumn)
|
||||||
{
|
{
|
||||||
// select host_id, GROUP_CONCAT(parent_host_id ORDER BY weight) FROM icinga_host_inheritance group by host_id;
|
if ($this->db instanceof \Zend_Db_Adapter_Pdo_Pgsql) {
|
||||||
|
$groupColumn = "ARRAY_TO_STRING(ARRAY_AGG(parent_$relColumn ORDER BY weight), ',')";
|
||||||
|
} else {
|
||||||
|
$groupColumn = "GROUP_CONCAT(parent_$relColumn ORDER BY weight SEPARATOR ',')";
|
||||||
|
}
|
||||||
$query = $this->db->select()
|
$query = $this->db->select()
|
||||||
->from([
|
->from([
|
||||||
'oi' => "${baseTable}_inheritance"
|
'oi' => "${baseTable}_inheritance"
|
||||||
], [
|
], [
|
||||||
$relColumn,
|
$relColumn,
|
||||||
"GROUP_CONCAT(parent_$relColumn ORDER BY weight SEPARATOR ',')"
|
$groupColumn
|
||||||
])
|
])
|
||||||
->group($relColumn)
|
->group($relColumn)
|
||||||
->order("LENGTH(GROUP_CONCAT(parent_$relColumn ORDER BY weight SEPARATOR ','))");
|
->order("LENGTH($groupColumn)");
|
||||||
|
|
||||||
// pgsql: ARRAY_TO_STRING(ARRAY_AGG(---), ',') -> order?
|
|
||||||
|
|
||||||
return $this->db->fetchPairs($query);
|
return $this->db->fetchPairs($query);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user