Skip to content

Commit 1e0f882

Browse files
committed
fixed bug when fetching results in version 3.5
1 parent 5bdd183 commit 1e0f882

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

src/Bolt/BoltConnection.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ public function __construct(BoltFactory $factory, ?V3 $boltProtocol, ConnectionC
6969
$this->factory = $factory;
7070
$this->boltProtocol = $boltProtocol;
7171
$this->config = $config;
72+
if ($boltProtocol) {
73+
$this->serverState = 'READY';
74+
}
7275
}
7376

7477
/**

src/Bolt/BoltResult.php

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
use function count;
1919
use Generator;
2020
use Iterator;
21-
use Laudis\Neo4j\Enum\ConnectionProtocol;
2221

2322
/**
2423
* @psalm-import-type BoltCypherStats from \Laudis\Neo4j\Contracts\FormatterInterface
@@ -75,21 +74,17 @@ public function getIt(): Generator
7574
*/
7675
public function iterator(): Generator
7776
{
78-
if ($this->connection->getProtocol() === ConnectionProtocol::BOLT_V3()) {
79-
yield from $this->rows;
80-
} else {
81-
$i = 0;
82-
while ($this->meta === null) {
83-
$this->fetchResults();
84-
foreach ($this->rows as $row) {
85-
yield $i => $row;
86-
++$i;
87-
}
77+
$i = 0;
78+
while ($this->meta === null) {
79+
$this->fetchResults();
80+
foreach ($this->rows as $row) {
81+
yield $i => $row;
82+
++$i;
8883
}
8984
}
9085

9186
if ($this->finishedCallback) {
92-
call_user_func($this->finishedCallback, $this->meta ?? []);
87+
call_user_func($this->finishedCallback, $this->meta);
9388
}
9489
}
9590

@@ -153,6 +148,6 @@ public function __destruct()
153148

154149
public function discard(): void
155150
{
156-
$this->connection->discard($this->qid);
151+
$this->connection->discard($this->qid === -1 ? null : $this->qid);
157152
}
158153
}

0 commit comments

Comments
 (0)