diff --git a/src/Promise/PromiseMany.php b/src/Promise/PromiseMany.php index e81ed4333..c24fc45c1 100644 --- a/src/Promise/PromiseMany.php +++ b/src/Promise/PromiseMany.php @@ -50,7 +50,7 @@ public function __construct(ORMInterface $orm, string $target, array $query = [] */ public function __loaded(): bool { - return empty($this->orm); + return $this->orm === null; } /** @@ -78,6 +78,12 @@ public function __resolve() return $this->resolved; } + if ($this->query === []) { + // nothing to proxy to + $this->orm = null; + return null; + } + foreach ($this->orm->getRepository($this->target)->findAll($this->query + $this->where) as $item) { $this->resolved[] = $item; }