• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/lib/orm/query/query.php
  • Класс: Bitrix\Main\ORM\Query\Query
  • Вызов: Query::checkFilterHandlerAggregation
protected function checkFilterHandlerAggregation(Filter $filter)
{
	foreach ($filter->getConditions() as $condition)
	{
		$is_having = false;

		if ($condition instanceof Filter)
		{
			// subfilter
			$is_having = $this->checkFilterHandlerAggregation($condition);
		}
		else
		{
			// check if it is not a boolean/exists condition
			if ($condition->getDefinition() !== null)
			{
				// regular condition
				$chain = $this->filter_chains[$condition->getDefinition()];
				$last = $chain->getLastElement();

				$is_having = $last->getValue() instanceof ExpressionField && $last->getValue()->isAggregated();

				// check if value is a field and has aggregation
				if (!$is_having && $condition->getValue() instanceof ColumnExpression)
				{
					$chain = $this->filter_chains[$condition->getValue()->getDefinition()];
					$last = $chain->getLastElement();

					$is_having = $last->getValue() instanceof ExpressionField && $last->getValue()->isAggregated();

					// actually if it has happened, we need to add group by the first column
				}
			}
		}

		if ($is_having)
		{
			return true;
		}
	}

	return false;
}