Skip to content

Commit ecc49c0

Browse files
committed
changed generator behaviour if it is on protocol 3
1 parent 02c9d17 commit ecc49c0

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

src/Bolt/BoltResult.php

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function __construct(BoltConnection $connection, int $fetchSize, int $qid
4646
$this->qid = $qid;
4747
$this->connection->incrementOwner();
4848
if ($this->connection->getProtocol() === ConnectionProtocol::BOLT_V3()) {
49-
$this->pull();
49+
$this->fetchResults();
5050
}
5151
}
5252

@@ -82,17 +82,21 @@ public function getIt(): Generator
8282
*/
8383
public function iterator(): Generator
8484
{
85-
$i = 0;
86-
while ($this->meta === null) {
87-
$this->fetchResults();
88-
foreach ($this->rows as $row) {
89-
yield $i => $row;
90-
++$i;
85+
if ($this->connection->getProtocol() === ConnectionProtocol::BOLT_V3()) {
86+
yield from $this->rows;
87+
} else {
88+
$i = 0;
89+
while ($this->meta === null) {
90+
$this->fetchResults();
91+
foreach ($this->rows as $row) {
92+
yield $i => $row;
93+
++$i;
94+
}
9195
}
92-
}
9396

94-
if ($this->finishedCallback) {
95-
call_user_func($this->finishedCallback, $this->meta);
97+
if ($this->finishedCallback) {
98+
call_user_func($this->finishedCallback, $this->meta);
99+
}
96100
}
97101
}
98102

0 commit comments

Comments
 (0)