FilterRenderer: support SimpleQuery

fixes #1670
This commit is contained in:
Thomas Gelf 2018-10-30 18:02:32 +01:00
parent f9cb40fbbd
commit dfdc7d327b
1 changed files with 9 additions and 4 deletions

View File

@ -8,6 +8,7 @@ use Icinga\Data\Filter\FilterChain;
use Icinga\Data\Filter\FilterExpression;
use Icinga\Data\Filter\FilterNot;
use Icinga\Data\Filter\FilterOr;
use Icinga\Data\SimpleQuery;
use InvalidArgumentException;
use RuntimeException;
use Zend_Db_Adapter_Abstract as DbAdapter;
@ -44,12 +45,16 @@ class FilterRenderer
return new DbExpr($this->render());
}
public static function applyToQuery(Filter $filter, DbSelect $query)
public static function applyToQuery(Filter $filter, $query)
{
if (! $filter->isEmpty()) {
$renderer = new static($filter, $query->getAdapter());
$renderer->extractColumnMap($query);
$query->where($renderer->toDbExpression());
if ($query instanceof DbSelect) {
$renderer = new static($filter, $query->getAdapter());
$renderer->extractColumnMap($query);
$query->where($renderer->toDbExpression());
} elseif ($query instanceof SimpleQuery) {
$query->applyFilter($filter);
}
}
return $query;