From 5be48fc923cf532837f9b072c33a9fad6c6e5257 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 3 Dec 2015 13:53:34 +0100 Subject: [PATCH] DbQuery: Do not call Zend_Db_Select::columns() unless it's necessary This makes it possible to just use a DbQuery as "union container" without ever calling from() on it. --- library/Icinga/Data/Db/DbQuery.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/library/Icinga/Data/Db/DbQuery.php b/library/Icinga/Data/Db/DbQuery.php index f5b730dce..860b7fe25 100644 --- a/library/Icinga/Data/Db/DbQuery.php +++ b/library/Icinga/Data/Db/DbQuery.php @@ -153,7 +153,10 @@ class DbQuery extends SimpleQuery $select->group($group); } - $select->columns($this->columns); + if (! empty($this->columns)) { + $select->columns($this->columns); + } + $this->applyFilterSql($select); if ($this->hasLimit() || $this->hasOffset()) { @@ -333,7 +336,9 @@ class DbQuery extends SimpleQuery $this->applyFilterSql($count); $group = $this->getGroup(); if ($this->useSubqueryCount || $group) { - $count->columns($this->columns); + if (! empty($this->columns)) { + $count->columns($this->columns); + } if ($group) { $count->group($group); }