diff --git a/src/Bolt/BoltConnection.php b/src/Bolt/BoltConnection.php index 9e3cf8ce..0254db2e 100644 --- a/src/Bolt/BoltConnection.php +++ b/src/Bolt/BoltConnection.php @@ -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; } diff --git a/src/Bolt/BoltResult.php b/src/Bolt/BoltResult.php index 35b3c6b1..3a41d573 100644 --- a/src/Bolt/BoltResult.php +++ b/src/Bolt/BoltResult.php @@ -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); } } diff --git a/src/Bolt/BoltUnmanagedTransaction.php b/src/Bolt/BoltUnmanagedTransaction.php index a6998969..ef814cef 100644 --- a/src/Bolt/BoltUnmanagedTransaction.php +++ b/src/Bolt/BoltUnmanagedTransaction.php @@ -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; @@ -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(),