mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-27 15:54:03 +02:00
commit
12856da971
@ -4,7 +4,7 @@
|
|||||||
namespace Icinga\Exception;
|
namespace Icinga\Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exception thrown if a query contains invalid parameters
|
* Exception thrown if a query encountered an error
|
||||||
*/
|
*/
|
||||||
class QueryException extends IcingaException
|
class QueryException extends IcingaException
|
||||||
{
|
{
|
||||||
|
@ -12,6 +12,7 @@ use Icinga\Data\Filter\FilterExpression;
|
|||||||
use Icinga\Exception\IcingaException;
|
use Icinga\Exception\IcingaException;
|
||||||
use Icinga\Exception\NotImplementedError;
|
use Icinga\Exception\NotImplementedError;
|
||||||
use Icinga\Exception\ProgrammingError;
|
use Icinga\Exception\ProgrammingError;
|
||||||
|
use Icinga\Exception\QueryException;
|
||||||
use Icinga\Web\Session;
|
use Icinga\Web\Session;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -855,7 +856,6 @@ abstract class IdoQuery extends DbQuery
|
|||||||
protected function customvarNameToTypeName($customvar)
|
protected function customvarNameToTypeName($customvar)
|
||||||
{
|
{
|
||||||
$customvar = strtolower($customvar);
|
$customvar = strtolower($customvar);
|
||||||
// TODO: Improve this:
|
|
||||||
if (! preg_match('~^_(host|service)_([a-zA-Z0-9_]+)$~', $customvar, $m)) {
|
if (! preg_match('~^_(host|service)_([a-zA-Z0-9_]+)$~', $customvar, $m)) {
|
||||||
throw new ProgrammingError(
|
throw new ProgrammingError(
|
||||||
'Got invalid custom var: "%s"',
|
'Got invalid custom var: "%s"',
|
||||||
@ -870,11 +870,20 @@ abstract class IdoQuery extends DbQuery
|
|||||||
return array_key_exists($name, $this->joinedVirtualTables);
|
return array_key_exists($name, $this->joinedVirtualTables);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the query column of a already joined custom variable
|
||||||
|
*
|
||||||
|
* @param string $customvar
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
* @throws QueryException If the custom variable has not been joined
|
||||||
|
*/
|
||||||
protected function getCustomvarColumnName($customvar)
|
protected function getCustomvarColumnName($customvar)
|
||||||
{
|
{
|
||||||
if (isset($this->customVars[($customvar = strtolower($customvar))])) {
|
if (! isset($this->customVars[($customvar = strtolower($customvar))])) {
|
||||||
$this->customVars[strtolower($customvar)] . '.varvalue';
|
throw new QueryException('Custom variable %s has not been joined', $customvar);
|
||||||
}
|
}
|
||||||
|
return $this->customVars[$customvar] . '.varvalue';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function aliasToColumnName($alias)
|
public function aliasToColumnName($alias)
|
||||||
@ -882,9 +891,19 @@ abstract class IdoQuery extends DbQuery
|
|||||||
return $this->idxAliasColumn[$alias];
|
return $this->idxAliasColumn[$alias];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the alias of a column expression as defined in the {@link $columnMap} property.
|
||||||
|
*
|
||||||
|
* @param string $alias Potential custom alias
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function customAliasToAlias($alias)
|
public function customAliasToAlias($alias)
|
||||||
{
|
{
|
||||||
return $this->idxCustomAliases[$alias];
|
if (isset($this->idxCustomAliases[$alias])) {
|
||||||
|
return $this->idxCustomAliases[$alias];
|
||||||
|
}
|
||||||
|
return $alias;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user