diff --git a/library/Icinga/Repository/DbRepository.php b/library/Icinga/Repository/DbRepository.php index d7cbe29ba..617bfb80c 100644 --- a/library/Icinga/Repository/DbRepository.php +++ b/library/Icinga/Repository/DbRepository.php @@ -54,7 +54,7 @@ abstract class DbRepository extends Repository implements Extensible, Updatable, * * This may be initialized by repositories which are going to make use of table aliases. It allows to provide * alias-less column names to be used for a statement. The array needs to be in the following format: - *

+     * 
      *  array(
      *      'table_name' => array(
      *          'column1',
@@ -62,7 +62,7 @@ abstract class DbRepository extends Repository implements Extensible, Updatable,
      *          'alias2' => 'column3'
      *      )
      *  )
-     * 

+     * 
      *
      * @var array
      */
@@ -823,13 +823,17 @@ abstract class DbRepository extends Repository implements Extensible, Updatable,
             return $statementAliasTableMap[$alias] === $table;
         }
 
+        $prefixedAlias = $table . '.' . $alias;
+        if (isset($statementAliasTableMap[$prefixedAlias])) {
+            return true;
+        }
+
         $statementColumnTableMap = $this->getStatementColumnTableMap();
         if (isset($statementColumnTableMap[$alias])) {
             return $statementColumnTableMap[$alias] === $table;
         }
 
-        $prefixedAlias = $table . '.' . $alias;
-        return isset($statementAliasTableMap[$prefixedAlias]) || isset($statementColumnTableMap[$prefixedAlias]);
+        return isset($statementColumnTableMap[$prefixedAlias]);
     }
 
     /**
diff --git a/library/Icinga/Repository/Repository.php b/library/Icinga/Repository/Repository.php
index 121966e42..b00a2a278 100644
--- a/library/Icinga/Repository/Repository.php
+++ b/library/Icinga/Repository/Repository.php
@@ -67,7 +67,7 @@ abstract class Repository implements Selectable
      * The query columns being provided
      *
      * This must be initialized by concrete repository implementations, in the following format
-     * 

+     * 
      *  array(
      *      'baseTable' => array(
      *          'column1',
@@ -75,7 +75,7 @@ abstract class Repository implements Selectable
      *          'alias2' => 'column3'
      *      )
      *  )
-     * 
+ * * * @var array */ @@ -101,12 +101,12 @@ abstract class Repository implements Selectable * The filter columns being provided * * This may be intialized by concrete repository implementations, in the following format - *

+     * 
      *  array(
      *      'alias_or_column_name',
      *      'label_to_show_in_the_filter_editor' => 'alias_or_column_name'
      *  )
-     * 
+ * * * @var array */ @@ -137,7 +137,7 @@ abstract class Repository implements Selectable * The sort rules to be applied on a query * * This may be initialized by concrete repository implementations, in the following format - *

+     * 
      *  array(
      *      'alias_or_column_name' => array(
      *          'order'     => 'asc'
@@ -154,7 +154,7 @@ abstract class Repository implements Selectable
      *          // Ascendant sort by default
      *      )
      *  )
-     * 
+ * * Note that it's mandatory to supply the alias name in case there is one. * * @var array @@ -1094,13 +1094,17 @@ abstract class Repository implements Selectable return $aliasTableMap[$alias] === $table; } + $prefixedAlias = $table . '.' . $alias; + if (isset($aliasTableMap[$prefixedAlias])) { + return true; + } + $columnTableMap = $this->getColumnTableMap(); if (isset($columnTableMap[$alias])) { return $columnTableMap[$alias] === $table; } - $prefixedAlias = $table . '.' . $alias; - return isset($aliasTableMap[$prefixedAlias]) || isset($columnTableMap[$prefixedAlias]); + return isset($columnTableMap[$prefixedAlias]); } /**