diff --git a/library/Icinga/Repository/Repository.php b/library/Icinga/Repository/Repository.php
index 58f199f1b..9a40a3d6f 100644
--- a/library/Icinga/Repository/Repository.php
+++ b/library/Icinga/Repository/Repository.php
@@ -19,7 +19,7 @@ use Icinga\Util\String;
*
* - Concrete implementations need to initialize Repository::$queryColumns
* - The datasource passed to a repository must implement the Selectable interface
- * - The datasource must yield an instance of QueryInterface when its select() method is called
+ * - The datasource must yield an instance of Queryable when its select() method is called
*
*/
abstract class Repository implements Selectable
diff --git a/library/Icinga/Repository/RepositoryQuery.php b/library/Icinga/Repository/RepositoryQuery.php
index 86527a66e..d70afd457 100644
--- a/library/Icinga/Repository/RepositoryQuery.php
+++ b/library/Icinga/Repository/RepositoryQuery.php
@@ -43,7 +43,6 @@ class RepositoryQuery implements QueryInterface
public function __construct(Repository $repository)
{
$this->repository = $repository;
- $this->query = $repository->getDataSource()->select();
}
/**
@@ -68,7 +67,10 @@ class RepositoryQuery implements QueryInterface
*/
public function from($target, array $columns = null)
{
- $this->query->from($target, $this->prepareQueryColumns($target, $columns));
+ $this->query = $this->repository
+ ->getDataSource()
+ ->select()
+ ->from($target, $this->prepareQueryColumns($target, $columns));
$this->target = $target;
return $this;
}