Skip to content

Commit

Permalink
fix: Consume results if server state in streaming
Browse files Browse the repository at this point in the history
  • Loading branch information
exaby73 committed Aug 3, 2024
1 parent 585335e commit 2d7bdd9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Bolt/BoltConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public function setTimeout(float $timeout): void

public function consumeResults(): void
{
if ($this->protocol()->serverState !== ServerState::STREAMING || $this->protocol()->serverState !== ServerState::TX_STREAMING) {
if ($this->protocol()->serverState !== ServerState::STREAMING && $this->protocol()->serverState !== ServerState::TX_STREAMING) {
$this->subscribedResults = [];
return;
}
Expand Down
4 changes: 0 additions & 4 deletions src/Bolt/BoltResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,6 @@ public function __destruct()

public function discard(): void
{
$serverState = $this->connection->protocol()->serverState;
if ($serverState !== ServerState::STREAMING || $serverState !== ServerState::TX_STREAMING) {
return;
}
$this->connection->discard($this->qid === -1 ? null : $this->qid);
}
}
6 changes: 6 additions & 0 deletions src/Bolt/BoltUnmanagedTransaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

namespace Laudis\Neo4j\Bolt;

use Bolt\enum\ServerState;
use Laudis\Neo4j\Common\TransactionHelper;
use Laudis\Neo4j\Contracts\FormatterInterface;
use Laudis\Neo4j\Contracts\UnmanagedTransactionInterface;
Expand Down Expand Up @@ -127,6 +128,11 @@ public function runStatement(Statement $statement)
$parameters = ParameterHelper::formatParameters($statement->getParameters(), $this->connection->getProtocol());
$start = microtime(true);

$serverState = $this->connection->protocol()->serverState;
if (in_array($serverState, [ServerState::STREAMING, ServerState::TX_STREAMING])) {
$this->connection->consumeResults();
}

try {
$meta = $this->connection->run(
$statement->getText(),
Expand Down

0 comments on commit 2d7bdd9

Please sign in to comment.