From b2d86df660ab6d5c9ab71e07a97e223c60451428 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 30 May 2017 13:57:58 +0200 Subject: [PATCH] DbRepository: Fix that virtual tables are not resolved for statement columns --- library/Icinga/Repository/DbRepository.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/library/Icinga/Repository/DbRepository.php b/library/Icinga/Repository/DbRepository.php index eb77567a5..d7cbe29ba 100644 --- a/library/Icinga/Repository/DbRepository.php +++ b/library/Icinga/Repository/DbRepository.php @@ -26,6 +26,8 @@ use Icinga\Util\StringHelper; *
  • Differentiation between statement and query columns
  • *
  • Capability to join additional tables depending on the columns being selected or used in a filter
  • * + * + * @method DbConnection getDataSource($table = null) */ abstract class DbRepository extends Repository implements Extensible, Updatable, Reducible { @@ -262,8 +264,8 @@ abstract class DbRepository extends Repository implements Extensible, Updatable, */ protected function applyTableAlias($table, $virtualTable = null) { - $tableAliases = $this->getTableAliases(); if (! is_array($table)) { + $tableAliases = $this->getTableAliases(); if ($virtualTable !== null && isset($tableAliases[$virtualTable])) { return array($tableAliases[$virtualTable] => $table); } @@ -588,6 +590,12 @@ abstract class DbRepository extends Repository implements Extensible, Updatable, } $table = $newTable; + } else { + $virtualTables = $this->getVirtualTables(); + if (isset($virtualTables[$table])) { + $virtualTable = $table; + $table = $virtualTables[$table]; + } } return $this->prependTablePrefix($this->applyTableAlias($table, $virtualTable));